Math lib is not included in standard C lib. You need to link to it
specifically. Use
gcc -lm sample.c
On Fri, 21 Jul 2000, Sergey Panasyuk wrote:
> Hi, I am trying to compile some c code and have problems with gcc.
> This is my code saved as sample.c
> #include<stdio.h>
> #include<math.h>
>
> int main(void)
> {
> printf("%f", sin(3.14));
> }
>
> then at terminal I tipe gcc sample.c and got error that sin is undefined.
> Samething happened for cos, sqrt.
> I did compile the same code using VC++ 6.
> I think the code compiled with no errors but is not linked.
>
>
>