使用(自定义)GCC 4.x或5.x时,Boost构建无法进行C ++ 11功能检查

时间:2016-10-03 07:59:03

标签: c++ c++11 gcc boost b2

我需要在Fedora 24机器上构建Boost 1.62和1.63,但是使用GCC 4.9.3或GCC 5.4.0(取决于版本CUDA,这就是我需要旧编译器的原因)。但是,如果我按this answer中所述设置自定义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)的功能?

2 个答案:

答案 0 :(得分:8)

使用Boost 1.62.0 + GCC 4.x,Boost 1.62.0 + GCC 5.x和Boost 1.65.1 + GCC 5.x测试以下溶液。 YMMV与其他Boost版本,但我认为它没有理由不起作用。

为了这个例子,我们假设:

  • 您希望使用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路)

现在:

  1. (可选:确保您拥有Boost喜欢的库,例如:zlibbzip2lzmazstdiconv,{ {1}})
  2. icu
  3. 通过运行cd /path/to/sources/of/boost-1.62.0/
  4. 来提升构建系统
  5. ./bootstrap.sh
  6. echo "using gcc : 5.4 : /the/path/to/g++-5.4 : <cxxflags>-std=c++11 ;" > ./tools/build/src/user-config.jam(N是系统中的核心数)
  7. ./b2 --toolset=gcc-5.4 -j N
  8. 注意:

    • 行动2和3的顺序并不重要。
    • 飘柔! GCC 6.x或更高版本不会发生这种情况。
    • 如果您需要GCC 5.4.0(非最终版)C ++ 14支持,则可以将./b2 install --prefix=/dest/path替换为c++11。如果您使用的是其他GCC版本,请记住在标准最终确定之前,您实际上并未获得其开关。因此,C ++ 11用于表示c++1y和C ++ 17为--std=c++1x,并且随着GCC版本在标准最终确定后发布,开关也会发生变化。

答案 1 :(得分:7)

我有同样的问题。 看起来,因为你是交叉编译,所以boost构建系统试图检查你的编译器是否支持所有这些c ++ 11特性。 问题是,为了做到这一点,构建系统编译一张代码。 其中一个文件是:boost_1_62_0 / libs / rational / test / constexpr_test.cpp 然后,构建系统执行使用交叉编译器时没有人会想到的...它试图在主机上执行生成的二进制文件...它显然失败了。 所有这些cxx11_测试都会发生这种情况。我也遇到了这个问题,这是一个问题。因此,我无法使用OpenWRT为我的Raspberries构建Boost.Fiber。