sqrt is not find???

I was writing a simple program in linux, which includes sqrt function of c.
I included the math.h. But when I use gcc to compile it, it gave an error message:

/home/murat/tmp/ccOv9upo.o(.text+0x4b): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status

I checked the /usr/include, it does have the file math.h.
then I tried sqrtf, this aint woking either.

I am using Mandrake 10, the kernel is 2.6.3-7mdk.
Does anybody know what is WRONG???
How should I change it?

thanks

The program is not linked to the math library. #include just makes those symbols available for compilation but not linking.

Include "-lm" to the command line.

1 Like

thanks. :slight_smile:
it works now. And it is time for getting familiar with gcc compiling options, I think.