FS#45202 - [boost] recompile static libraries with -fPIC

Attached to Project: Arch Linux
Opened by Nax (Nax) - Thursday, 04 June 2015, 13:15 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Saturday, 10 December 2016, 19:40 GMT
Task Type Feature Request
Category Packages: Extra
Status Closed
Assigned To Ionut Biru (wonder)
Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

Hello, if you want to link the static boost libraries into a shared-object you get the error:

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/libboost_system.a: error adding symbols: Bad value

In order to make it possible to link the static boost libs into a shared object they must be compiled with -fPIC.

Steps to reproduce:
* Create a new file (i.e. test.cpp) which uses some parts of boost (i.e. boost::filesystem)
* run:
% g++ -std=c++14 test.cpp -shared /usr/lib/libboost_system.a /usr/lib/libboost_filesystem.a -o libtest.so

This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Saturday, 10 December 2016, 19:40 GMT
Reason for closing:  Fixed
Comment by Bartłomiej Piotrowski (Barthalion) - Saturday, 10 December 2016, 19:40 GMT
It's been over a year and I added -fPIC in the meantime. Remember to pass -fPIC to your g++ line as well.

Loading...