I want use bit7z library in my project, on windows system, use the precomlied library work fine, but on Ubuntu system, use the precomplied library not work,
build.cs
Type = ModuleType.External;
string PlatformDir = Target.Platform.ToString();
string IncPath = Path.Combine(ModuleDirectory, "include");
string LibPath = Path.Combine(ModuleDirectory, "lib", PlatformDir);
string BinaryPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "../../../Binaries/ThirdParty", PlatformDir));
if (Target.Platform == UnrealTargetPlatform.Win64)
{
PublicSystemIncludePaths.Add(IncPath);
string LibName = "bit7z.lib";
PublicAdditionalLibraries.Add(Path.Combine(LibPath, LibName));
string DLLName = "7z.dll";
PublicDelayLoadDLLs.Add(DLLName);
RuntimeDependencies.Add(Path.Combine(BinaryPath, DLLName));
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
PublicSystemIncludePaths.Add(IncPath);
string LibName = "libbit7z64.a";
PublicAdditionalLibraries.Add(Path.Combine(LibPath, LibName));
// 添加额外的链接标志
// PublicAdditionalLibraries.Add("dl");
// string DLLName = "7z.so";
// PublicRuntimeLibraryPaths.Add(BinaryPath);
// RuntimeDependencies.Add(Path.Combine(BinaryPath, DLLName));
}
build will report link error
ld.lld: Error : relocation R_X86_64_PC32 cannot be used against symbol 'vtable for bit7z::FixedBufferExtractCallback'; recompile with -fPIC
0>>>> defined in /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a(fixedbufferextractcallback.cpp.o)
0>>>> referenced by fixedbufferextractcallback.cpp
0>>>> fixedbufferextractcallback.cpp.o:(bit7z::FixedBufferExtractCallback::FixedBufferExtractCallback(bit7z::BitInputArchive const&, unsigned char*, unsigned long)) in archive /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a
0>ld.lld: Error : relocation R_X86_64_PC32 cannot be used against symbol 'vtable for bit7z::FixedBufferExtractCallback'; recompile with -fPIC
0>>>> defined in /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a(fixedbufferextractcallback.cpp.o)
0>>>> referenced by fixedbufferextractcallback.cpp
0>>>> fixedbufferextractcallback.cpp.o:(bit7z::FixedBufferExtractCallback::FixedBufferExtractCallback(bit7z::BitInputArchive const&, unsigned char*, unsigned long)) in archive /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a
0>ld.lld: Error : relocation R_X86_64_PC32 cannot be used against symbol 'vtable for bit7z::FixedBufferExtractCallback'; recompile with -fPIC
0>>>> defined in /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a(fixedbufferextractcallback.cpp.o)
0>>>> referenced by fixedbufferextractcallback.cpp
0>>>> fixedbufferextractcallback.cpp.o:(bit7z::FixedBufferExtractCallback::FixedBufferExtractCallback(bit7z::BitInputArchive const&, unsigned char*, unsigned long)) in archive /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a
0>ld.lld: Error : relocation R_X86_64_PC32 cannot be used against symbol 'vtable for bit7z::FixedBufferExtractCallback'; recompile with -fPIC
0>>>> defined in /home/prkj/Extend/workspace/01-lab/Bit7zTest/Plugins/P_Bit7Z/Source/ThirdParty/Bit7Z/lib/Linux/libbit7z64.a(fixedbufferextractcallback.cpp.o)
0>>>> referenced by fixedbufferextractcallback.cpp
0>>>> fixedbufferextractcallback.cpp.o:(bit7z::FixedBufferExtractCallba
then I build the library from source , build command
cmake ../ -DCMAKE_C_COMPILER=/opt/EpicGames/UE_5.3/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v22_clang-16.0.6-centos7/x86_64-unknown-linux-gnu/bin/clang -DCMAKE_CXX_COMPILER=/opt/EpicGames/UE_5.3/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v22_clang-16.0.6-centos7/x86_64-unknown-linux-gnu/bin/clang++ -DCMAKE_BUILD_TYPE=Release -DBIT7Z_GENERATE_PIC=ON -DBIT7Z_LINK_LIBCPP=ON -DBIT7Z_CUSTOM_7ZIP_PATH=/home/prkj/Downloads/7zip-23.01
cmake --build . -j --config Release
I have used the system clang, not work , then use the ue clang, also not work, still report same link error.
Any help would be greatly appreciated