Bug 2177728

Summary: Cannot link boost-program-options static library to a shared library due to not being compiled with -fPIC option
Product: [Fedora] Fedora Reporter: Hedayat Vatankhah <hedayatv>
Component: boostAssignee: Jonathan Wakely <jwakely>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 37CC: codonell, denis.arnaud_fedora, jwakely, laurent.rineau__fedora, mcermak, trodgers
Target Milestone: ---Keywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hedayat Vatankhah 2023-03-13 14:17:05 UTC
Description of problem:
Trying to link boost program options static library to a shared library, I get the following error:

/usr/bin/ld: /usr/lib64/libboost_program_options.a(value_semantic.o): warning: relocation against `_ZTIN5boost10wrapexceptINS_15program_options18invalid_bool_valueEEE' in read-only section `.text._ZNK5boost10wrapexceptINS_15program_options18invalid_bool_valueEE7rethrowEv[_ZNK5boost10wrapexceptINS_15program_options18invalid_bool_valueEE7rethrowEv]'
/usr/bin/ld: /usr/lib64/libboost_program_options.a(options_description.o): relocation R_X86_64_PC32 against symbol `_ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21' can not be used when making a shared object; recompile with -fPIC


Version-Release number of selected component (if applicable):
boost-static-1.78.0-9.fc37.x86_64

How reproducible:
100%

Comment 1 Jonathan Wakely 2023-03-15 21:11:21 UTC
I don't think Boost's build system actually supports this:
https://github.com/boostorg/build/issues/366

It might need to be done by patching the build in Fedora to force it to always use -fPIC.

Comment 2 Jonathan Wakely 2023-03-15 21:14:18 UTC
Then again, maybe it just needs something like:

./b2 cxxflags=-fPIC cflags=-fPIC

https://lists.boost.org/boost-build/2016/08/28769.php