Problem using math library

Tom Tran
Wed Dec 17 18:24:00 GMT 2003

I have problem using function in math.h.  gcc gives undefined reference
Here is a sample of my tstpow.c program:

#include <math.h>

int main()
   double d;

   d = pow(2.0, 3.0);
  return 0;

I compiled the program with:
    gcc tstpow.c

gcc gave this error:
   undefined reference pow

I tried other functions s.a. sqrt(), sin(), etc.  Same problem.
Other header files (s.a. <stdio.h> <string.h> <stdlib.h> work fine.

Please help.

Tom Tran

More information about the Gcc-help mailing list