trouble compiling gmp-chudnovsky.c

Alex Greenbank alex at greenbank.org
Tue May 2 12:52:37 CEST 2006


Hello,

>Hello,
>
>Thanks for a great website!
>
>I am unable to compile gmp-chudnovsky.c on my Linux PC.  The gmp library  
>compiled fine, but when I try to compile gmp-chudnovsky.c (renamed to  
>pi.c) as follows:
>
>[lloyd at localhost demos]$ [lloyd at localhost demos]$ gcc pi.c -lgmp
>
>I get the following output:
>
>/home/lloyd/tmp/ccGVTUBR.o: In function `my_sqrt_ui':
>pi.c:(.text+0x52): undefined reference to `sqrt'
>pi.c:(.text+0xdd): undefined reference to `sqrt'
>/home/lloyd/tmp/ccGVTUBR.o: In function `build_sieve':
>pi.c:(.text+0x1797): undefined reference to `sqrt'
>collect2: ld returned 1 exit status
>
>I can't figure out why the sqrt function seems hidden from the linker.
>
>I'd appreciate any help.

sqrt() is in the math library, add the -lm switch:-

$ gcc pi.c -lgmp -lm

Ta,

-Alex


___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com



More information about the gmp-discuss mailing list