我将不胜感激任何关于如何解决以下问题的建议:
CMakeFiles/es.dir/epollsock.cpp.o: In function `cds_lfht_new':
/usr/include/urcu/rculfhash.h:167: undefined reference to `_cds_lfht_new'
CMakeFiles/es.dir/epollsock.cpp.o: In function `WordCounterRCU::removeHashTable()':
~/WordCounterRCU.hpp:37: undefined reference to `cds_lfht_destroy'
CMakeFiles/es.dir/epollmsg.cpp.o: In function `cds_lfht_new':
/usr/include/urcu/rculfhash.h:167: undefined reference to `_cds_lfht_new'
CMakeFiles/es.dir/epollmsg.cpp.o: In function `WordCounterRCU::addWord(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
~/WordCounterRCU.hpp:69: undefined reference to `cds_lfht_add_unique'
CMakeFiles/es.dir/epollmsg.cpp.o: In function `WordCounterRCU::getCount()':
~/WordCounterRCU.hpp:96: undefined reference to `cds_lfht_count_nodes'
我的CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(effective_server)
set(CMAKE_CXX_STANDARD 11)
<< part with liburcu >>
find_package (Threads)
set(SOURCE_FILES ...)
add_executable(effective_server ${SOURCE_FILES})
target_link_libraries (effective_server ${CMAKE_THREAD_LIBS_INIT} -lurcu)
if (LIBURCU_FOUND)
include_directories( ${LIBURCU_INCLUDE_DIR} )
target_link_libraries(effective_server ${LIBURCU_LIBRARY})
endif(LIBURCU_FOUND)
find_package( ZLIB REQUIRED )
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIRS} )
target_link_libraries( effective_server ${ZLIB_LIBRARIES} )
endif( ZLIB_FOUND )
带有 liburcu 的部分是从 https://github.com/markusa/netsniff-ng_filter/tree/master/src/cmake/modules 复制的。
我已经检查了LIBURCU_INCLUDE_DIR和LIBURCU_LIBRARY,它们似乎是正确的。
谢谢!
这是关于一个缺失的链接器标志 -lurcu-cds。它应该是: target_link_libraries (effective_server ${CMAKE_THREAD_LIBS_INIT} -lurcu -lurcu-cds(