C++ 缺少boost库命名

C++ 缺少boost库命名,c++,boost,building,C++,Boost,Building,我下载了boost并构建了它,这不是第一次,但后来事情开始变得奇怪起来 起初,我在编译我的项目(使用boost)时遇到以下错误: 所以我去检查是否一切就绪,发现我的boost lib文件没有通常的库命名,也就是说它们看起来像:libboost\u线程.a,libboost\u系统.a,libboost\u日期时间.a,而不是-mt,-d等等 我不记得我到底是如何构建的,但如果我尝试运行: boost\u src\u dir>/b2 threading=multi-link=static vari

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

起初,我在编译我的项目(使用boost)时遇到以下错误:

所以我去检查是否一切就绪,发现我的boost lib文件没有通常的库命名,也就是说它们看起来像:
libboost\u线程.a
libboost\u系统.a
libboost\u日期时间.a
,而不是
-mt
-d
等等

我不记得我到底是如何构建的,但如果我尝试运行:
boost\u src\u dir>/b2 threading=multi-link=static variant=debug,release

我得到:


谢谢。

在boost repo中,如果您希望它位于非默认位置,请确保已使用
--prefix=
运行了
/bootstrap.sh
。不过,你不需要这个论点

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


此外,请确保您的机器具有正确的版本。关于报告的
错误:“libboost\u atomic.a”的名称冲突,我使用了我的(OpenSUSE 13.1 64位)

我只是在这里总结一下解释和解决方案(Nitzan Tomer给出了解释和解决方案,@Samidamaru的回答没有提供解决方案)

问题是关于
--布局
规范。有关
--layout
选项,请参见
b2--help

在Linux上,默认布局是
system
,这意味着对于所有类型的构建,库都是使用以下模式创建的:
libboost.a
(或Windows上的
.lib
)。 这意味着将为
debug
release
变量创建相同的文件。由于Nitzan通过传递
variant=debug请求了这两个变量,因此release
创建的文件将相互覆盖<代码>b2
将此报告为错误

各种布局及其效果总结
boost{boost version tag}
(例如,
boost\u 1\u 68
)中间目录不是为其他布局创建的。

我运行了
/bootstrap.sh
,但没有
--前缀(因为默认位置对我来说已经足够好了),我下载了该目录,对mint来说应该可以。从
stage/lib中删除所有
*.a
文件不会改变任何内容。似乎它不喜欢我同时要求调试和发布啊,是的,我没发现!我认为您不能要求它同时将其编译为调试和发布。如果您想这样做,我建议构建两次boost并安装到两个不同的目录,以便您可以在需要时选择所需的目录。混合调试和发布代码是一种不好的做法,但这就是为什么不呢?因此,我将能够让不同的lib版本尝试传递--build type=complete。这应该可以构建两个库:)我设法使用:
/b2--build type=complete--layout=versioned
来构建所有库,但不幸的是,它不能解决我的编译错误。
/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()'
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.
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()
+-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ | | --layout | +-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ | | versioned | tagged | system | +-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ | Library file name: | libboost_{lib name}-{toolset}[-mt]-{ABI tag}-{ARCH tag}-{boost ver tag}.lib | libboost_{lib name}[-mt]-{ABI tag}.lib | libboost_{lib name}.lib | +-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ | Header file directory:| include/boost_{boost ver tag} | include | include | +-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ | Notes: | Default on Windows. | Different toolsets (eg. different | Default on Linux. | | | All variations can be created in the same folder. | compiler versions), architecture and | All variations must be | | | See "Library naming" at | address-model CANNOT be generated in | created in separate | | | https://www.boost.org/doc/libs/1_68_0/more/getting_started/unix-variants.html | the same folder. But relase/debug and | folders. | | | The corresponding b2 options are also indicated on this page. | single/multi-threaded can be. | | +-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+ /tools/boost | +--- lib | +--- include +--- boost_{boost version tag} | +--- boost +--- accumulators +--- algorithm etc.