11Zip
11Zip copied to clipboard
Compilation error when linking against 11Zip with CMake
When adding 11Zip to a scikit-build-core CMake project using add_subdirectory, the following error is thrown:
/usr/bin/ld: extlibs/11Zip/libelzip.a(elzip.cpp.o): warning: relocation against `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' in read-only section `.text.unlikely'
/usr/bin/ld: extlibs/11Zip/libelzip.a(elzip.cpp.o): relocation R_X86_64_PC32 against symbol `_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
In order to fix it, the following command needs to be added to 11Zip CMakeLists.txt:
target_compile_options(elzip PRIVATE -fPIC)
Probably, the reason for this error is that scikit-build-core generates a dynamic library, which is then called by python