No fPIC for Object Library
CMake version: v3.9.3
OS: Linux x86_64
Probably does not matter but, Target(cross-compiling): Linux ARM
I've recently hit a linking issue on ARM with new(std::nothrow)
:
relocation R_ARM_MOVW_ABS_NC against `_ZSt7nothrow' can not be used when making a shared object; recompile with -fPIC
When trying to use the objects from a library target:
add_library([target a] OBJECT [the files])
Linking:
add_library([target b] SHARED $<TARGET_OBJECTS:[target a]> [target b files])
To solve the issue manually, I did:
target_compile_options([target a] PRIVATE "-fPIC")
Should the Object Library behave here the same way a typical library behaves? Adding -fPIC
automatically on Linux?