我需要在 Fedora 24 机器上构建 Boost 1.62 和 1.63,但使用 GCC 4.9.3 或 GCC 5.4.0(取决于 CUDA 版本,这就是我需要旧编译器的原因)。但是如果我按照中所述设置自定义 GCC 版本这个答案 and run
/b2 --toolset=gcc-5.4.0 stage
令我懊恼的是,我现在看到:
- 32-bit : no
- 64-bit : yes
- arm : no
- mips1 : no
- power : no
- sparc : no
- x86 : yes
- symlinks supported : yes
- C++11 mutex : no
- lockfree boost::atomic_flag : yes
- Boost.Config Feature Check: cxx11_auto_declarations : no
- Boost.Config Feature Check: cxx11_constexpr : no
- Boost.Config Feature Check: cxx11_defaulted_functions : no
- Boost.Config Feature Check: cxx11_final : yes
- Boost.Config Feature Check: cxx11_hdr_tuple : no
- Boost.Config Feature Check: cxx11_lambdas : no
- Boost.Config Feature Check: cxx11_noexcept : no
- Boost.Config Feature Check: cxx11_nullptr : no
- Boost.Config Feature Check: cxx11_rvalue_references : no
- Boost.Config Feature Check: cxx11_template_aliases : no
- Boost.Config Feature Check: cxx11_thread_local : no
- Boost.Config Feature Check: cxx11_variadic_templates : yes
也就是说,许多 C++11 功能被认为缺失,但实际上它们不应该缺失。当使用发行版的 GCC 版本 (6.2.1) 构建它时,不会发生这种情况。
为什么会发生这种情况?我应该怎样做才能使 Boost 构建识别我的 GCC 5.4.0(或 4.9.3)的功能?
The following solution was tested with Boost 1.62.0 + GCC 4.x, Boost 1.62.0 + GCC 5.x and Boost 1.65.1 + GCC 5.x. YMMV with other Boost versions but I see no reason why it shouldn't work.
为了这个例子,我们假设:
- 您想使用 GCC 5.4 构建 Boost
- g++ 5.4 二进制文件位于
/some/where/g++-5.4
- 您已下载 Boost 源并将其解压到
/path/to/sources/of/boost-1.62.0/
- (也许)你想安装 Boost
/dest/path
- 您有 N 个核心(因此您希望并行构建 N 路)
Now:
- (可选:确保您拥有 Boost 喜欢的库,例如:
zlib
, bzip2
, lzma
, zstd
, iconv
, icu
)
cd /path/to/sources/of/boost-1.62.0/
- 通过运行引导构建系统
./bootstrap.sh
echo "using gcc : 5.4 : /the/path/to/g++-5.4 : <cxxflags>-std=c++11 ;" > ./tools/build/src/user-config.jam
-
./b2 --toolset=gcc-5.4 -j N
(N 是系统上的核心数量)
./b2 install --prefix=/dest/path
Notes:
- 操作 2 和 3 的顺序并不重要。
- 麾! GCC 6.x 或更高版本不会发生这种情况。
- 您可以更换
c++11
with c++1y
如果您想要 GCC 5.4.0 的(未最终确定的)C++14 支持。如果您使用不同的 GCC 版本,请记住,在标准最终确定之前,您实际上并没有获得可用的开关。因此 C++11 过去的意思是--std=c++1x
C++17 是--std=c++1z
随着 GCC 版本在标准最终确定后发布,这些开关也会发生变化。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)