title: undefined reference to...collect2:error:ld returned 1 exit status
body: <p>I am writing a simple program to compile from the command prompt. There is an <code>app1</code> program that uses a class located in a separate file. The class <code>sample1</code> has a header file <code>sample1.h</code> where all the function declarations exist. The <code>sample1.cpp</code> file contains the function definitions.</p>
  <p><code>app1.cpp</code>:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &quot;sample1.h&quot;
  
  using namespace std;
  
  int main()
  {
      sample1 t;
      cout&lt;&lt;&quot;The program is ending&quot;&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  <p><code>sample1.h</code>:</p>
  <pre><code>#ifndef SAMPLE1_H
  #define SAMPLE1_H
  
  class sample1
  {       
      public:
      sample1();
  };
  
  #endif
  </code></pre>
  <p><code>sample1.cpp</code>:</p>
  <pre><code>#include&lt;sample1.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  sample1::sample1()
  {
      cout&lt;&lt;&quot;This error sucks&quot;&lt;&lt;endl;
  }
  </code></pre>
  <p>I am compiling this program using Windows Subsystem for Linux. However, when I try to compile with <code>g++ 'app1.cpp' -o app1</code>, I get this error:
  <a href="https://i.stack.imgur.com/VlMDB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VlMDB.jpg" alt="enter image description here" /></a></p>
  <p>I get that the error is telling me that the program cannot find the constructor <code>sample::sample()</code> but why is that? I included the header file in the program. These 3 files all exist in the same folder.</p>