我在使用 gcc-8 在 Ubuntu 16.04 LTS 上构建 Boost 库时遇到问题。
目前,我需要构建调试和发布构建的库。
以下是我用于构建用于调试构建库的命令:
$ ./bootstrap.sh --with-libraries=all --with-python-version=3.5 --with-icu="/usr/include/x86_64-linux-gnu/"
###################
# For Debug build #
###################
$ ./b2 toolset=gcc-8 cxxflags="-std=c++17" variant=debug
#####################
# For Release build #
#####################
$ ./b2 toolset=gcc-8 cxxflags="-std=c++17" variant=release
问题是,即使将变体指定为 debug
或 release
,构建也会使用相同的名称构建库。
每个生成步骤都会覆盖上一个命令生成的库。
如何根据此处提到的文档获取可能带有后缀-d
的调试库?
我还试图研究这里提到的boost-build
参考。但是我收到错误404页面找不到。
此处找到的 Boost Build 的旧参考似乎也没有在调试和发布模式下构建 Boost 库的必要细节。
提前谢谢。
如--help
信息中所述,在 Unix 类型系统上,--layout
的默认值为 system
,它不添加允许多个构建变体共存的标记:
--layout=<layout> Determine whether to choose library names and header
locations such that multiple versions of Boost or
multiple compilers can be used on the same system.
-- versioned -- Names of boost binaries include
the Boost version number, name and version of
the compiler and encoded build properties. Boost
headers are installed in a subdirectory of
<HDRDIR> whose name contains the Boost version
number.
-- tagged -- Names of boost binaries include the
encoded build properties such as variant and
threading, but do not including compiler name
and version, or Boost version. This option is
useful if you build several variants of Boost,
using the same compiler.
-- system -- Binaries names do not include the
Boost version number or the name and version
number of the compiler. Boost headers are
installed directly into <HDRDIR>. This option is
intended for system integrators building
distribution packages.
The default value is 'versioned' on Windows, and
'system' on Unix.
您可以使用--layout=tagged
或--layout=versioned
选项在构建时允许多个变体。
还有一个--buildid=ID
选项,也列在--help
输出中,可让您在结果上放置自定义标记。在您想要较短的名称或使事情尽可能简单的情况下很有用。但要注意,因为它是自定义消费者,即构建系统,不太可能知道如何处理名称。
https://www.boost.org/doc/libs/1_62_0/tools/build/tutorial.html
debug-symbols=on variant=debug
选项集构建调试配置:
<debug-symbols> on, off - Create debug symbols.
<variant> debug, release, profile - Build debug, release or profile version.
-a
选项也很有用,因为它构建了所有可能的配置组合。
这样b2 -a install
可以满足所有可能的需求。