Hi,
I have built the 3rd party Accellera SystemC library using CMake on Centos 7 with devtoolset-7. I can successfully link my C++ application to that library, on the same platform.
I also need to link my application to the same library, on Ubuntu 18.04. But when I try to do so I get error:
/usr/bin/ld: ,snip>/SystemC/rel-2.3.3/x64-linux/_release/libsystemc.a(instance_specific_extensions.cpp.o): relocation R_X86_64_32 against symbol `_ZGVZN9tlm_utils42instance_specific_extension_container_pool8instanceEvE4inst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
devtoolset-7 has gcc 7.3.1, ld v.2.28
Ubuntu 18.04 has gcc v.7.4.0, ld v.2.30
I think the following CMake article is relevant:
CMP0083 — CMake 3.14.7 Documentation
but I am not sure what I need to do. Do I need to add:
set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
to the build of the SystemC library, or should I change the build of my application?