简体   繁体   English

关于使用CMake使用lib-urcu进行编译的未定义参考

[英]Undefined reference on compiling with lib-urcu with CMake

I would appreciate any piece of advice on how can I resolve following: 对于如何解决以下问题,我将不胜感激:

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'

My CMakeLists.txt: 我的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 )

The part with liburcu is copied from https://github.com/markusa/netsniff-ng_filter/tree/master/src/cmake/modules . liburcu的部分从https://github.com/markusa/netsniff-ng_filter/tree/master/src/cmake/modules复制。

I have checked LIBURCU_INCLUDE_DIR and LIBURCU_LIBRARY, they seem to be correct. 我已经检查了LIBURCU_INCLUDE_DIR和LIBURCU_LIBRARY,它们似乎是正确的。

Thank you! 谢谢!

It was about a missing linker flag -lurcu-cds. 这是关于缺少链接器标记-lurcu-cds的。 It should be: target_link_libraries (effective_server ${CMAKE_THREAD_LIBS_INIT} -lurcu -lurcu-cds) 应该是:target_link_libraries(有效服务器$ {CMAKE_THREAD_LIBS_INIT} -lurcu -lurcu-cds)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM