[C++-sig] compile libboost_python.a with '-fPIC' flag on x86_64

Grant Tang gtang at blake.bcm.tmc.edu
Fri Feb 17 18:33:48 CET 2006

Neal Becker wrote:

> Grant Tang wrote:
>> Neal Becker wrote:
>>> Grant Tang wrote:
>>>> Hi,
>>>> I need to compile a static boost.python library with '-fPIC' CFLAGS. I
>>>> don't know how to do it with bjam/jamfile.
>>>> Since my platform is x86_64 based, the libboost_python.a compiled
>>>> without '-fPIC' will not make my project compiled.
>>>> Thanks,
>>>> Grant
>>> Should you be using the .so versions which would be built with -fPIC?
>>> What os?
>> My os is linux.
>> The libboost_python.so works fine. But we want to statically compile our
>> software with boost.python, so it will not ask our end user to install
>> libboost_python first, just to minimize the dependency. We have a dozen
>> of dependency libraries. All other I can make their static library
>> compiled with '-fPIC' CFLAGS, since they use MAKEFILE instead of jamfile.
> I understand.
> Not sure, but I think if you link using /usr/lib64/libboost.so.xxx instead
> of -lboostxxx, it will do a static link of the library.  Let me know if
> that works.

This way I still link a shared library. libboost_python.so is a symbolic
link to libboost_pyton.so.1.33.1. 

I link my software with libboost_python.a, it will be statically link. It
works on x86 32 bit Linux. But on x86_64 system, since we compile our
software as a .so package and want to statically link libboost_python.a,
linker complain we need compile libboost_python.a with '-fPIC' flags. Same
complain for all other dependency packages we need.

More information about the Cplusplus-sig mailing list