架构 x86_64 的未定义符号:“boost::this_thread::interruption_point()”

问题描述 投票:0回答:3

我正在使用 make 构建一些东西,但出现以下错误。 我不知道该怎么做,而且我在 java 之外的经验也很有限。

我尝试了 boost 版本 1.80.0、1.39.0 和 1.46.1,但都有相同的错误。

有人可以帮忙吗?

Undefined symbols for architecture x86_64:
  "boost::this_thread::interruption_point()", referenced from:
      boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in sip_client.cpp.o
      boost::condition_variable::do_wait_until(boost::unique_lock<boost::mutex>&, boost::detail::real_platform_timepoint const&) in sip_client.cpp.o
  "boost::detail::get_current_thread_data()", referenced from:
      boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*) in sip_client.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/sip_client] Error 1
make[1]: *** [examples/sip_client/CMakeFiles/sip_client.dir/all] Error 2
make: *** [all] Error 2
c++ boost
3个回答
0
投票

添加编译器选项-lboost_thread。

更新:

websocketpp 附带 CMakeFiles,用于您尝试构建的示例。我无法构建那些提供的 makefile,而且我对 cmake 知之甚少,无法修复它。不过,我确实通过在 Linux 上运行这个示例来构建无需 cmake 的示例:

cd websocketpp/examples/sip_client

clang++ sip_client.cpp -lpthread -lboost_thread -Wall -g

0
投票

cmake 找不到 boost_thread-mt 库,必须手动添加到 cmake。

我将此行添加到我的 CMakeLists.txt 文件中,它拾取了它

target_link_libraries(BoostTest ${Boost_LIBRARY_DIR}/libboost_thread-mt.dylib)


0
投票

我添加了boost_thread到 设置(WEBSOCKETPP_PLATFORM_LIBS pthread rt)

# g++
if (CMAKE_COMPILER_IS_GNUCXX)
    if (NOT APPLE)
        set (WEBSOCKETPP_PLATFORM_LIBS pthread boost_thread rt)
© www.soinside.com 2019 - 2024. All rights reserved.