[Linux] fPIC Issue while compiling project as a shared library

Hi there,
I’m trying to compile my project as a DLL / shared library under Linux (bShouldCompileAsDll and Monolithic). Compilation itself works without any issues, since it’s a clean project to just test out the feature, however I’m getting linker issues.

[1/2] Link (lld) libProTestServerServer.so
ld.lld: error: can't create dynamic relocation R_X86_64_32S against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in /home/repos/UnrealEngine/Engine/Source/ThirdParty/Ogg/libogg-1.2.2/lib/Unix/x86_64-unknown-linux-gnu/libogg.a(framing.o)
>>> referenced by framing.c:292
>>>               framing.o:(ogg_page_checksum_set) in archive /home/repos/UnrealEngine/Engine/Source/ThirdParty/Ogg/libogg-1.2.2/lib/Unix/x86_64-unknown-linux-gnu/libogg.a


I took a quick look at the ThirdParty folders and noticed that the compiled _fPIC variants are actually included in the unreal dependencies and I think from what I saw non-monolithic builds would actually use them. However looking at the UBT I think it doesn’t build a shared-library if you don’t build in monolithic mode.

Would be really glad, if someone could give me some pointers or actually knows a way on how I can force the dependencies to use the _fPIC libraries. If you have any resources on how UBT actually gathers all its linker-dependencies, I’d be glad to read through those as well.

1 Like