boost lib命名丢失 [英] boost lib naming are missing

查看:154
本文介绍了boost lib命名丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了boost并构建了它,这不是第一次,但是随后事情似乎变得很奇怪.

I've downloaded boost and built it, and not for the first time, but then things started to seem weird.

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

At first I got these errors while compiling my project (which uses 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.alibboost_system.alibboost_date_time.a ,而不是-mt-d等.

So I went to check if everything is in place and found out that the boost lib files I have don't have the usual library naming, that is they just look like: libboost_thread.a, libboost_system.a, libboost_date_time.a, instead of the -mt, -d and so on.

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

I don't remember how exactly I built it, but if I try to run:
boost_src_dir > ./b2 threading=multi link=static variant=debug,release
I get:

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.

不太清楚发生了什么事,以前我做过这件事很顺利..
有什么想法吗?

Not quite sure what's going on, the previous times I've done this it went pretty smooth..
Any ideas?

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

I'm using linux mint (17.2 x64), boost 1.59 and use it with cmake like so:

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()

谢谢.

推荐答案

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

我只是在这里总结说明和解决方案(@Nitzan Tomer提供了简短地),为此,@ Samidamaru的答案没有提供解决方案.

I'm just summarizing here the explanation and solution (which @Nitzan Tomer gave briefly above, and for which, @Samidamaru 's answer did not provide a resolution).

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

The problem was about --layout specification. See b2 --help for the --layout option.

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

On Linux the default layout is system, which means that for all kind of builds, the libraries are created with the schema: libboost_<library-name>.a (or .lib on Windows). It means that the same file would be created both for debug and release variant. Since Nitzan requested both variants by passing variant=debug,release the created files would overwrite each other. b2 reported this as an error.


+-----------------------+-------------------------------------------------------------------------------+----------------------------------------+-------------------------+
|                       |                                                                  --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选项时才能创建单线程版本.

Of course on Linux the .a and .so post-fixes are used vs. .lib and .dll on Windows. The lib prefix is omitted from DLL names on Windows. On Windows the single-threaded versions can be created only if the runtime-link=static option was set.

对于标题,仍然在指示的文件夹下创建通常" boost目录. --prefix=/tools/boostb2,然后为versioned布局创建以下目录结构:

For headers, the "usual" boost directory is still created under the indicated folder.
It means that if you passed e.g. --prefix=/tools/boost to b2, then the following directory structure is created for the versioned layout:


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

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

The boost_{boost version tag} (e.g. boost_1_68) intermediate directory is not created for other layouts.

这篇关于boost lib命名丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆