title: Calling function from another file declared in a header file
body: <p>I want to call a function that is in sin.c, and the main file is in test1.c </p>
  
  <p>and the files look like this:</p>
  
  <p>file test1.c:</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
      #include "sin.h"
  
      int main(){
         float angle;
         double sinValue;
  
         printf("Please enter a angle: ");
         scanf("%f", &amp;angle);
  
         sinValue = sin(angle);
  
         printf("the sin value of this angle is: %2.7f.", sinValue);
         printf("program terminated");
  
         return 0;
      }
  </code></pre>
  
  <p>this is the header file:</p>
  
  <p>In sin.h:</p>
  
  <pre><code>extern double sin(float angle);
  </code></pre>
  
  <p>In file sin.c:</p>
  
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  #define EPSILON 0.0000001;
  
  int fact(int n);
  
  double sin(float angle){
  
      float rad;
      float pi = M_PI;
      double newSin, oldSin;
      double n = 1.0;
      double token;
  
  
      //find the radians
      rad = angle * M_PI / 180.0;
      newSin = rad;
  
      //find the approxmate value of sin(x)
      while((newSin - oldSin) &gt; EPSILON ){
  
          oldSin = newSin;
          token = 2.0 * n - 1.0;
          newSin = oldSin + pow(-1.0, n) * pow(rad, token) / fact(token);
          n++;
      }
  
      return newSin;
  }
  </code></pre>
  
  <p>The problem is when I compile the test1.c the error message shows: </p>
  
  <pre><code>sin.h:1:15: warning: conflicting types for built-in function ‘sin’      [enabled by default]
   extern double sin(float angle);
                 ^
  /tmp/ccxzixfm.o: In function `main':
  test1.c:(.text+0x39): undefined reference to `sin'
  collect2: error: ld returned 1 exit status
  make: *** [test1] Error 1
  </code></pre>
  
  <p>It is already declared in the header file and I also included that header file, so what is the error. I'm so confused.</p>
  
  <p>Thanks before, John.</p>
  
  <p>I use the "make" command to compile the test1.c </p>
  
  <p>Here is the compilation process:</p>
  
  <pre><code>zxz111@ubuntu:~/Desktop/sin$ ls
  sin.c  sin.c~  sin.h  test1.c  test1.c~
  zxz111@ubuntu:~/Desktop/sin$ make test1
  cc     test1.c   -o test1
  In file included from test1.c:3:0:
  sin.h:1:15: warning: conflicting types for built-in function ‘sin’ [enabled by default]
   extern double sin(float angle);
                 ^
  /tmp/ccxzixfm.o: In function `main':
  test1.c:(.text+0x39): undefined reference to `sin'
  collect2: error: ld returned 1 exit status
  make: *** [test1] Error 1
  zxz111@ubuntu:~/Desktop/sin$ make test1
  </code></pre>