weird C problem
Ralf Corsepius
rc040203 at freenet.de
Wed Aug 11 16:39:55 UTC 2010
On 08/11/2010 06:31 PM, Dj YB wrote:
> Hello,
>
> I have written a small program in C and I am using the math.h library using
> #include<math.h>
> so far everything is good.
> when using the function sqrt I get the next error:
>
> $ cc a.c
> /tmp/ccTaon4H.o: In function `main':
> a.c:(.text+0x3e): undefined reference to `sqrt'
>
> to be sure I checked man sqrt:
>
> SYNOPSIS
>
> #include<math.h>
>
> double sqrt(double x);
A couple of lines later you will find this sentence:
" Link with -lm."
> I have no idea what is wrong, any suggestions are welcome.
Math functions are not contained in libc, they are in a separate library
called libm.
=> cc a.c -lm
Ralf
More information about the users
mailing list