Boost logo

Boost-Build :

From: arvid_at_[hidden]
Date: 2007-06-20 12:56:21

I have recently bumped into a problem when building shared libraries.

On linux, all object files that are to be linked into a shared library has to
built with the -fPIC option. Similarly, on MacOS X, object files that are built
into an application should be built with -mdynamic-no-pic (-fPIC is the default

The problem I have encountered is that -fPIC (and -mdynamic-no-pic) does not
seem to be a feature known to boost build, and hence, it is not properly
propagated as a requirement to dependencies. For instance, if I build the
following project.

lib a : a.cpp ;
lib b : b.cpp : <library>a/<link>static ;
like this: bjam -a link=shared
i.e. building a static library "a", and a shared library "b" linking against
I will get the following error:
/usr/bin/ld: bin/gcc-4.1.2/debug/link-static/liba.a(a.o): relocation R_X86_64_32
against `__gxx_personality_v0' can not be used when making a shared object;
recompile with -fPIC
bin/gcc-4.1.2/debug/link-static/liba.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
    "g++"    -o "bin/gcc-4.1.2/debug/" -Wl,-h -Wl, -shared
-Wl,--start-group "bin/gcc-4.1.2/debug/b.o"
"bin/gcc-4.1.2/debug/link-static/liba.a"    -Wl,--end-group -g 
I believe the proper solution would be to add a features, e.g. "relocatable", so
that liba.a can be built both with -fPIC and without. 
Arvid Norberg

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at