我需要在Fedora 24机器上构建Boost 1.62和1.63,但使用GCC 4.9.3或GCC 5.4.0(取决于CUDA版本,这就是我需要旧编译器的原因)。但是,如果我设置自定义GCC版本,在这个答案中描述并运行
/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)的功能?
使用Boost 1.62.0 + GCC 4测试了以下解决方案。x, Boost 1.62.0 + GCC 5。和Boost 1.65.1 + GCC 5.x。YMMV与其他Boost版本,但我认为没有理由不应该工作
对于这个例子,我们假设:
- 你想用GCC 5.4构建Boost g++ 5.4二进制文件位于
- 你已经下载了Boost源代码并将它们解压缩到
/path/to/sources/of/boost-1.62.0/
- (也许)你想安装Boost到
/dest/path
- 你有N个内核(所以你想并行构建N-ways)
/some/where/g++-5.4
:
- (可选:确保您有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
指出:
- 动作2和3的顺序不重要。
- 喜乐!这在GCC 6中不会发生。
- 如果你想要GCC 5.4.0(未最终确定)的c++ 14支持,你可以用
c++1y
替换c++11
。如果您正在使用不同的GCC版本,请记住,在标准最终确定之前,您实际上并没有获得可用的开关。因此,c++ 11过去表示--std=c++1x
, c++ 17表示--std=c++1z
,随着GCC版本在标准定稿后发布,开关也会改变。
我也有同样的问题。
看起来,因为你正在交叉编译,boost构建系统试图检查你的编译器是否支持所有的c++11特性。问题是,为了做到这一点,构建系统编译了一段代码。其中一个文件是:boost_1_62_0/libs/rational/test/constexpr_test.cpp
然后,构建系统做了在使用交叉编译器时没有人会想到的事情…它试图在主机上执行生成的二进制文件…这显然是失败的。所有的cxx11_测试都是这样。我也有这个问题,这是一个问题。因此,我无法构建Boost。我的覆盆子纤维与OpenWRT。