提升lib命名缺失

时间:2015-10-07 12:04:55

标签: c++ boost building

我已经下载了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()'

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

我不记得我是如何建造它的,但如果我试图跑步:
-d
我明白了:

boost_src_dir > ./b2 threading=multi link=static variant=debug,release

不太确定发生了什么,以前我做过这件事它变得非常顺利..
有什么想法吗?

我使用linux mint(17.2 x64),提升1.59并将其与cmake一起使用,如下所示:

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.

感谢。

2 个答案:

答案 0 :(得分:1)

在您的提升仓库中,如果您希望将其设置为非默认位置,请确保您使用<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="container"><span>This is my text</span></div>运行./bootstrap.sh。你不需要这个论点。

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

另外,请确保您的计算机版本正确。我使用http://downloads.sourceforge.net/boost/boost_1_58_0.tar.bz2作为我的(OpenSUSE 13.1 64 bit)

答案 1 :(得分:1)

关于报告的error: Name clash for '<pstage/lib>libboost_atomic.a'

在这里,我只是总结一下解释和解决方案(@Nitzan Tomer提供了briefly above,而为此,@ Samidamaru的回答没有提供解决方案)。

问题与--layout规范有关。有关b2 --help选项,请参见--layout

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

各种布局及其效果的总结

+-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+
|                       |                                                                  --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.          |                         |
+-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+

当然,在Linux上使用.a.so后缀,而在Windows上则使用.lib.dll。 Windows上的DLL名称中省略了lib前缀。 在Windows上,只有设置了runtime-link=static选项,才能创建单线程版本。

对于标题,仍然在指示的文件夹下创建“通常的” boost目录。
这表示如果您传递了例如--prefix=/tools/boostb2,然后为versioned布局创建以下目录结构:

/tools/boost
         |
         +--- lib
         |
         +--- include
                  +--- boost_{boost version tag}
                                    |
                                    +--- boost
                                           +--- accumulators
                                           +--- algorithm
                                           etc.

没有为其他布局创建boost_{boost version tag}(例如boost_1_68)中间目录。