boost lib naming are missing

后端 未结 2 1168
北海茫月
北海茫月 2021-01-22 06:19

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

At first I got these errors while compiling my project (which use

相关标签:
2条回答
  • 2021-01-22 06:44

    Regarding the reported error: Name clash for '<pstage/lib>libboost_atomic.a':

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

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

    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.

    Summary of various layouts and their effect

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

    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.

    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.
    

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

    0 讨论(0)
  • 2021-01-22 06:54

    In your boost repo, make sure you've run ./bootstrap.sh with --prefix=<install directory> if you want it in a non default location. You don't need this argument though.

    You can run run the ./b2 command from the same directory after this to install boost once again with the --prefix=<install directory> option if required. You may have to remove all previous build files from your build/install directory before trying to do this.

    Also, make sure you have the correct version for your machine. I used http://downloads.sourceforge.net/boost/boost_1_58_0.tar.bz2 for mine (OpenSUSE 13.1 64 bit)

    0 讨论(0)
提交回复
热议问题