title: Unable to compile and link main.c to another source file using gcc
body: <p>I am trying to compile the following source file using <code>gcc -g -Wall -Wextra -pedantic -std=c99 -o main  -lm</code>. </p>
  
  <h2>source.h</h2>
  
  <pre><code>void simple_sum(void)
  </code></pre>
  
  <h2>source.c</h2>
  
  <pre><code>    #include "source.h"
      #include &lt;stdio.h&gt;
  
      void simple_sum(void)
      {
          int a, b;
          scanf("%d %d", &amp;a, &amp;b);
          printf("%d + %d = %d\n",a, b, a + b);
      }
  </code></pre>
  
  <h2>main.c</h2>
  
  <pre><code>#include "source.h"                                                                                                     
  #include &lt;stdio.h&gt;  
  
  int main(void)                                                                                                          
  {                                                                                                                           
      printf("\n");                                                                                                           
      simple_sum();     
  
      return 0;                                                                                                           
  }
  </code></pre>
  
  <p>I get following error:</p>
  
  <pre><code>gcc -g -Wall -Wextra -pedantic -std=c99 -o main  -lm
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function _start':
  (.text+0x20): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  Makefile:6: recipe for target 'main' failed
  make: *** [main] Error 1
  </code></pre>
  
  <p>Could someone please suggest how to fix this?</p>
  
  <h2>Edit</h2>
  
  <p>I get the following error when I run using <code>gcc -g -Wall main.c -o main</code></p>
  
  <p><code>/tmp/ccEAL4iG.o: In function</code>main':
  /home/a/aalto_university/functions/calculation/main.c:7: undefined reference to <code>simple_sum'
  collect2: error: ld returned 1 exit status</code></p>