encryptogroup / ABY

ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
GNU Lesser General Public License v3.0
463 stars 132 forks source link

Cmake with -fPIC #162

Closed Moriarty002 closed 3 years ago

Moriarty002 commented 4 years ago

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 ?

cacay commented 4 years ago

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
Moriarty002 commented 3 years ago

Thank you very much This problem was successfully solved