Hi,
The "sqrt" function is in libm, you should use: gcc PROGRAM_NAME -lm
Venkatesh
>
> Hi, all
>
> I had a function and cc it in redhat 7.2,
> but if I use
> $gcc PROGRAM_NAME,
> there will be error :
>
> /tmp/ccAXzZTF.o: In function `main':
> /tmp/ccAXzZTF.o(.text+0x32): undefined reference to `sqrt'
> collect2: ld returned 1 exit status
>
> but if I use -O or -O2 to gcc, it works well !!
> I do not know why, the following is source code
>
>
> #include <stdio.h>
> #include <math.h>
>
> int main(void)
> {
>
> double pi = M_PI;
> double pisqrt;
> long i;
>
> for (i = 0; i < 10000000; ++i) {
> pisqrt = sqrt(pi);
> }
> return 0;
> }
>
>
>
> _______________________________________________
> Redhat-devel-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-devel-list
>
_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list