[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: link err with #include<math.h>

> I got the following error with the attached program when attempting to
> compile with "gcc coil1.c".
> /tmp/ccc00256: In function `main':
> /tmp/ccc00256<.txt+0x92): undefined reference to `sqrt'
> I assume that this is a link error and that the required lib is not being
> included.  What am I doing wrong?

When including math.h, you need to use the "-lm" argument to gcc to tell it
to link to the math library. "gcc coil1.c -lm" should do the trick.

Hope that helps,


Reply to: