mulix <[EMAIL PROTECTED]> writes:

> I have the following code snippet:
> 
> #include <stdio.h>
> #include <math.h>
> 
> int main(void)
> {
>      double i;
>      i = sqrt(9);
>      printf("%e\n",i);
>      return 0;
> }
> 
> With g++, it compiles fine.
> With gcc, I get:
> "... undefined reference to 'sqrt'"
> "collect2: ld returned 1 exit status code"

> So... what am I missing? Is it gcc, ld, or the code is simply wrong?

The diagnostics actually tell you it's ld. Add -lm to your linking
rule, that is where sqrt lives.

-- 
Oleg Goldshmidt | BLOOMBERG L.P. (BFM) | [EMAIL PROTECTED]
"... We work by wit, and not by witchcraft;
 And wit depends on dilatory time." - W. Shakespeare.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to