0

Upon linking the boost 1.63.0 library libboost_regex-mt.a to a shared library I am getting the error:

/usr/bin/ld: /usr/local/lib/libboost_regex-mt.a(instances.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libboost_regex-mt.a: could not read symbols: Bad value 

I actually have compiled boost with -fPIC by using the following command (also see here):

./bjam '-sBUILD=<cxxflags>-fPIC <linkflags>-fPIC' --without-mpi --without-python --without-iostreams --layout=tagged link=shared,static 

When doing a bjam debug build, it seems that bjam only seems to honor the -fPIC for some source files, other files (including instances.cpp from the regex library) are compiled without it:

gcc.compile.c++ bin.v2/libs/regex/build/gcc-4.8/release/link-static/threading-multi/instances.o "g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -m64 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "bin.v2/libs/regex/build/gcc-4.8/release/link-static/threading-multi/instances.o" "libs/regex/build/../src/instances.cpp" 

How do I force bjam to use the -fPIC flag for all files?

1 Answer 1

1

Build boost 1.63, shared libraries :

./b2 --without-mpi --without-python --without-iostreams --layout=tagged link=shared runtime-link=shared link=static install 

threading=multi :

./b2 --without-mpi --without-python --without-iostreams --layout=tagged threading=multi link=shared runtime-link=shared link=static install 

"regex" result : ls *regex*

libboost_regex.a libboost_regex-mt.a libboost_regex-mt.so@ libboost_regex-mt.so.1.63.0* libboost_regex.so@ libboost_regex.so.1.63.0* 
Sign up to request clarification or add additional context in comments.

1 Comment

The threading_multi command still builds without -fPIC, e.g. "g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -m64 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "bin.v2/libs/regex/build/gcc-4.8/release/link-static/threading-multi/instances.o" "libs/regex/build/../src/instances.cpp"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.