title: C - Undefined reference to function error with linked files
body: <p>I started implementing a large program. But I ran into a massive issue. So here is very simplified code of my program. I have a separate .c file for my functions which is <strong>normal.c</strong> the main program is <strong>main.c</strong> and I have linked those two with <strong>cal.h</strong> header file.</p>
  
  <p>main.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "cal.h"
  
  void main()
  {
      int num1, num2, ans;
      num1=5;
      num2=5;
      ans=add(num1, num2);
      printf("%d" ,ans);
  }
  </code></pre>
  
  <p>normal.c</p>
  
  <pre><code>#include "cal.h"
  
  int add(int num1, int num2)
  {
      return num1+num2;
  }
  </code></pre>
  
  <p>cal.h</p>
  
  <pre><code>#ifndef CAL_H_INCLUDED
  #define CAL_H_INCLUDED
  #include &lt;errno.h&gt;
  
  int add(int num1, int num2);
  
  #endif // CAL_H_INCLUDED
  </code></pre>
  
  <p>but when I compile this, it gives out the error 
  <strong>..\main.c|10|undefined reference to `add'|</strong></p>
  
  <p>I'm using CodeBlocks v.13.12 in Windows 8.1 Any answer for this question is much appreciated. I tried with CodeLite as well, but the same error occurs. Thank you! </p>