From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-06-02 04:25:23
> /usr/bin/ld: bin.v2/libs/graph/build/gcc-3.4/debug/graphviz_graph_parser.o:
> relocation R_X86_64_32 can not be used when making a shared object;
> recompile with -fPIC
> bin.v2/libs/graph/build/gcc-3.4/debug/graphviz_graph_parser.o: could not
> read symbols: Bad value
> collect2: ld returned 1 exit status
> The problem is that the compiler flag -fPIC is not added to the command
> line when compiling the file graphviz_graph_parser.cpp
> I found the logic to add -fPIC in gcc.jam at line 88 but it seems to add
> -fPIC when _linking_ the shared library.
> The following patch corrects this and adds -fPIC to the compiler command
> line when compiling object files for shared libraries.
There are some problems with your solution, but they are minor compared to
link failure. I've committed the patch, thanks!
The following additional comment describes what's going on:
# This logic will add -fPIC for all compilations:
# lib a : a.cpp b ;
# obj b : b.cpp ;
# exe c : c.cpp a d ;
# obj d : d.cpp ;
# This all is fine, except that 'd' will be compiled with
# -fPIC even though it's not needed, as 'd' is used only in
# exe. However, it's hard to detect where a target is going to
# be used. Alternative, we can set -fPIC only when main target type
# is LIB but than 'b' will be compiled without -fPIC. In x86-64 that
# will lead to link errors. So, compile everything with -fPIC.
# Yet another alternative would be to create propagated <sharedable>
# feature, and set it when building shared libraries, but that's hard
# to implement and will increate target path length even more.
-- Vladimir Prus http://vladimir_prus.blogspot.com Boost.Build V2: http://boost.org/boost-build2
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk