[EMAIL PROTECTED] wrote:

>       I was trying to write a short program, which used
>       sqrt function.  Unfortunately, I ran into some
>       problems.
> 
>       Simple program like this:
> 
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
>       double i=16.0;
> 
>       printf("%lf", sqrt(i));
> 
>       return 0;
> }
> 
>       Does not compile correctly:
> 
> /tmp/cca157861.o: In function `main':
> /tmp/cca157861.o(.text+0x1b): undefined reference to `sqrt'
> 
>       I recall getting similar messages when I tried to
>       compile curses program without '-lncurses'.  But
>       AFAIK, there is no library needed for math.h
>       functions, correct?

Incorrect. You need to link with libm (add -lm to the link command).

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to