Compiling a static version of GMP for `-Wl,--whole-archive`
Cade Brown
brown.cade at gmail.com
Thu Jul 2 02:51:59 UTC 2020
Hello all,
I am trying to compile a static version of GMP (i.e. libgmp.a) on Linux
(Ubuntu) which I can embed fully in a .so I am compiling. I should be able
to do this as long as GMP contains PIC.
If I configure with `$ ./configure --enable-static --disable-shared
--with-pic --prefix=deps/prefix`
(and then make && make install)
I later compile my library with:
```
$ gcc -shared -O3 -std=c99 $(MY_OBJ) \
-Wl,--whole-archive deps/prefix/lib/libgmp.a -Wl,--no-whole-archive \
-o libmylibrary.so
```
Obviously, some steps are simplified for brevity, but I get the error:
```
usr/bin/ld: deps/prefix/lib/libgmp.a(dive_1.o): relocation R_X86_64_PC32
against symbol `__gmp_binvert_limb_table' can not be used when making a
shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
```
Any help, or experiences others have had embedding GMP into a shared
library?
Thanks,
~
Cade Brown
Working on MAGMA <https://icl.cs.utk.edu/magma/>
http://cade.site
http://chemicaldevelopment.us
More information about the gmp-discuss
mailing list