c++ can't compile a file
<p>I'm a beginner at c++ and I'm trying to write a program to find greatest common factor. In main i have:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include "longgcd.cpp"
int main(int argc, char* argv[]){
  long gcd(long m, long n);
  long m,n,g;
  m=atol(argv[1]);
  n=atol(argv[2]);
  g=gcd(m,n);
  std::cout&lt;&lt;"gcd("&lt;&lt;m&lt;&lt;","&lt;&lt;n&lt;&lt;")="&lt;&lt;g&lt;&lt;std::endl;
  return 0;
}
</code></pre>

<p>and then i put the subfunction into another file called longgcd.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
long gcd( long m, long n){
  long r;
  while(n !=0){
    r=m%n;
    m=n;
    n=r;
  }
  return m;
}
</code></pre>

<p>somehow longgcd.cpp can't compile. i get an error:</p>

<pre><code>/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [longgcd] Error 1
</code></pre>

<p>somehow I have difficulty running this program and making it work, i can't see whats wrong with it. Thanks for any help or suggestions.</p>
