problem with using shared library of GMP 5.0.1
tg at gmplib.org
Fri Sep 3 08:53:26 CEST 2010
Paul Zimmermann <Paul.Zimmermann at loria.fr> writes:
I'm not sure this is a GMP bug, but I report it since other users might have
hit this problem. When compiling GMP 5.0.1 on a Core 2 with the default
configure, then installing it and using it with say MPFR 3.0.0, I get when
/usr/bin/ld: /tmp/lib/libgmp.a(realloc.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/tmp/lib/libgmp.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libmpfr.la] Error 1
If I recompile GMP 5.0.1 with adding -fPIC in CFLAGS, and reinstall it, then
everything works fine.
This problem does not occur with GMP 4.3.2.
If you are building a MPFR shared library, you need to use -fPIC (or
-fpic) with GCC when compiling MPFR. GMP uses -fPIC, as you can see
from a GMP build log. You also need to link to GMP's shared library,
not the static library.
If you add -fPIC to CFLAGS when compiling GMP, you will compile also the
static library with PIC code, which is harmless except that it will slow
things down. (The shared library will then be compiled with -fPIC
More information about the gmp-bugs