gpt4 book ai didi

c++ - 缺少 boost lib 命名

转载 作者:搜寻专家 更新时间:2023-10-31 02:20:14 25 4
gpt4 key购买 nike

我下载了 boost 并构建了它,这不是第一次,但后来事情开始变得奇怪。

起初我在编译我的项目(使用 boost)时遇到了这些错误:

/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/exceptions.hpp:51: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/exceptions.hpp:84: undefined reference to `boost::system::system_category()'
/usr/local/include/boost/thread/pthread/thread_data.hpp:152: undefined reference to `vtable for boost::detail::thread_data_base'
/usr/local/include/boost/thread/pthread/thread_data.hpp:195: undefined reference to `boost::detail::get_current_thread_data()'
/usr/local/include/boost/thread/detail/thread.hpp:179: undefined reference to `boost::thread::start_thread_noexcept()'
/usr/local/include/boost/thread/detail/thread.hpp:741: undefined reference to `boost::thread::native_handle()'
/usr/local/include/boost/thread/detail/thread.hpp:767: undefined reference to `boost::thread::join_noexcept()'
/usr/local/include/boost/thread/detail/thread.hpp:779: undefined reference to `boost::thread::do_try_join_until_noexcept(timespec const&, bool&)'
/usr/local/include/boost/thread/pthread/condition_variable.hpp:84: undefined reference to `boost::this_thread::interruption_point()'
/usr/local/include/boost/thread/detail/thread.hpp:90: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/usr/local/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'

所以我去检查是否一切就绪,发现我的 boost lib 文件没有通常的库命名,它们看起来像:libboost_thread.a , libboost_system.a , libboost_date_time.a , 而不是 -mt , -d等等。

我不记得我是如何构建它的,但是如果我尝试运行:
boost_src_dir > ./b2 threading=multi link=static variant=debug,release
我得到:

error: Name clash for '<pstage/lib>libboost_atomic.a'
error:
error: Tried to build the target twice, with property sets having
error: these incompatible properties:
error:
error: - <debug-symbols>on <inlining>off <optimization>off <runtime-debugging>on <variant>debug
error: - <debug-symbols>off <define>NDEBUG <inlining>full <optimization>speed <runtime-debugging>off <variant>release
error:
error: Please make sure to have consistent requirements for these
error: properties everywhere in your project, especially for install
error: targets.

不太确定发生了什么,以前我这样做的时候很顺利..
有什么想法吗?

我正在使用 linux mint (17.2 x64),boost 1.59 并像这样将它与 cmake 一起使用:

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.36.0 COMPONENTS system thread shared_ptr)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
else()
message("can not find boost")
endif()

谢谢。

最佳答案

在你的 boost 仓库中,确保你已经运行了 ./bootstrap.sh--prefix=<install directory>如果您希望它位于非默认位置。不过你不需要这个参数。

您可以在此之后从同一目录运行 ./b2 命令以使用 --prefix=<install directory> 再次安装 boost如果需要选项。在尝试执行此操作之前,您可能必须从构建/安装目录中删除所有以前的构建文件。

此外,请确保您的机器版本正确。我用了http://downloads.sourceforge.net/boost/boost_1_58_0.tar.bz2对于我的(OpenSUSE 13.1 64 位)

关于c++ - 缺少 boost lib 命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32991736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com