By default, libboostpython.a
is compiled without -fPIC
. But I have to make a python extension and it is a dynamic library with -fPIC
that links to static libraries.
How can I compile a static library (libboostpython.a
) with -fPIC
from boost.python
?
There are a couple options you could use:
bjam ... cxxflags='-fPIC'
. That would compile every boost source file as position independent code.'-Wl,-rpath,$ORIGIN'
flag, so that when the dynamic linker searches for shared libraries required by your executable it looks for them in the directory where the executable is. See man ld.so for more details on $ORIGIN
.Note that if you already run bjam once you need to clear the targets first it is helpful also to print the commands by applying -d+2:
./bjam clean &&
./bjam -d+2 link=static cxxflags="-fPIC" install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With