When trying to compile a simple script with Gcc:
I get an error:Code:#include <stdio.h> #include <math.h> int main() { double a = cos(360); printf ("cos: %d\n\n", a); double b = sin(360); printf ("sin: %d\n\n", b); double c = tan(45); printf ("tan: %d\n\n", c); return 0; }
I compile via: gcc trig.c -o test, however when I compile using/tmp/cckLVeVp.o: In function `main':
trig.c.text+0x1b): undefined reference to `cos'
trig.c.text+0x3f): undefined reference to `sin'
trig.c.text+0x63): undefined reference to `tan'
collect2: ld returned 1 exit status
g++ trig.c -o test it works.
Why is it compiling with c++ compiler and not c compiler since it is a c script ????