簡體   English   中英

關於使用CMake使用lib-urcu進行編譯的未定義參考

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

對於如何解決以下問題,我將不勝感激:

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(有效服務器$ {CMAKE_THREAD_LIBS_INIT} -lurcu -lurcu-cds)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM