How do I use the library correctly with CMakeLists ?
I am new to cmake, I clone PALISADE project in path /home/kong/palisade-release
, created a new project named HESample
in path /home/kong/HESample
, and new a cpp file named palisade_example.cpp
,content from demo code, new a CMakeLists file:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
## Use -std=c++11 as default.
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=native -O3 -pthread -lrt" )
set(CMAKE_CXX_STANDARD 11)
project(palisade_example)
# PALISADE has a different path from my project
set(PALISADE_DIR /home/kong/palisade-release)
set(THIRDPARTYDIR ${PALISADE_DIR}/third-party)
find_library(PALISADEcore 1.6.0 REQUIRED)
find_library(PALISADEpke 1.6.0 REQUIRED)
add_executable(palisade_example palisade_example.cpp)
# link libraries
target_link_libraries(palisade_example PALISADEcore)
target_link_libraries(palisade_example PALISADEpke)
# include header files
target_include_directories(palisade_example PUBLIC
${PALISADE_DIR}/src
${PALISADE_DIR}/src/core/lib
${PALISADE_DIR}/src/pke/lib
${THIRDPARTYDIR}/include
${THIRDPARTYDIR}/cereal/include
)
When I execute it in clion, I get an error:
/usr/bin/ld: _ZN8lbcrypto27PseudoRandomNumberGenerator6m_prngE: TLS definition in //usr/local/lib/libPALISADEcore.so section .tbss mismatches non-TLS reference in CMakeFiles/palisade_example.dir/palisade_example.cpp.o
//usr/local/lib/libPALISADEcore.so: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/palisade_example.dir/build.make:83: recipe for target 'palisade_example' failed
make[3]: *** [palisade_example] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/palisade_example.dir/all' failed
make[2]: *** [CMakeFiles/palisade_example.dir/all] Error 2
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/palisade_example.dir/rule' failed
make[1]: *** [CMakeFiles/palisade_example.dir/rule] Error 2
Makefile:118: recipe for target 'palisade_example' failed
make: *** [palisade_example] Error 2
How should I solve this problem? Related Information:
- ubuntu 16.04
- PALISADE 1.6.0
- cmake 3.5.1
- gcc/g++ 7
Thanks!
Edited by theChildinus