Cmake with -fPIC
Moriarty002 opened this issue · comments
I had built ABY before , but after I tried to use it as share library and I got error below :
/usr/bin/ld: /lib/../lib/libencrypto_utils.a(socket.cpp.o): relocation R_X86_64_TPOFF32 against symbol``_ZN5boost4asio6detail15keyword_tss_ptrINS1_10call_stackINS1_14thread_contextENS1_16thread_info_baseEE7contextEE6value_E' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /lib/../lib/libaby.a(abyparty.cpp.o): relocation R_X86_64_PC32 against symbol ``_ZTV10ABYCircuit' can not be used when making a shared object; recompile with -fPIC
Seems that I need to add set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
in CmakeList.txt
but I didn't find any different between original makefile and new one .
Is there a good way to recompile ABY framework with flag -fPIC
?
CMake has a built-in variable for generating position independent code. Just add
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
to CMakeLists.txt
, or, better yet, pass it to CMake as a configuration variable (so you don't have to modify ABY):
# inside ABY/build
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
Thank you very much
This problem was successfully solved