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

ein*_*ica 8 c++ gcc boost c++11 b2

我需要在Fedora 24机器上构建Boost 1.62和1.63,但是使用GCC 4.9.3或GCC 5.4.0(取决于版本CUDA,这就是我需要旧编译器的原因).但是,如果我按照本答案中的描述设置自定义GCC版本并运行

/b2 --toolset=gcc-5.4.0 stage
Run Code Online (Sandbox Code Playgroud)

令我懊恼的是,我现在看到:

    - 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
Run Code Online (Sandbox Code Playgroud)

据说很多C++ 11的功能都应该丢失,而它们不应该丢失.使用发行版的GCC版本(6.2.1)构建它时不会发生这种情况.

为什么会发生这种情况,我该怎么做才能使Boost构建能够识别我的GCC 5.4.0(或4.9.3)的功能?

ein*_*ica 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. (可选:请确保您有升压喜欢有图书馆,如:zlib,bzip2,lzma,zstd,iconv,icu)
  2. cd /path/to/sources/of/boost-1.62.0/
  3. 通过运行来提升构建系统 ./bootstrap.sh
  4. echo "using gcc : 5.4 : /the/path/to/g++-5.4 : <cxxflags>-std=c++11 ;" > ./tools/build/src/user-config.jam
  5. ./b2 --toolset=gcc-5.4 -j N (N是系统上的核心数)
  6. ./b2 install --prefix=/dest/path

笔记:

  • 动作2和3的顺序无关紧要.
  • 麾!GCC 6.x或更高版本不会发生这种情况.
  • 您可以替换c++11使用c++1y,如果你想GCC 5.4.0的(未实施终结)C++ 14的支持.如果您使用的是其他GCC版本,请记住在标准最终确定之前,您实际上并未获得其开关.因此,C++ 11曾经意味着--std=c++1x和C++ 17,--std=c++1z并且随着GCC版本在标准定稿后发布,交换机也会发生变化.


Cla*_*ore 7

我有同样的问题.

看起来,因为你是交叉编译,所以boost构建系统试图检查你的编译器是否支持所有这些c ++ 11特性.问题是,为了做到这一点,构建系统编译一张代码.其中一个文件是这样的:boost_1_62_0/libs/rational/test/constexpr_test.cpp

然后,构建系统执行使用交叉编译器时没有人会想到的...它试图在主机上执行生成的二进制文件...它显然失败了.所有这些cxx11_测试都会发生这种情况.我也遇到了这个问题,这是一个问题.因此,我无法使用OpenWRT为我的Raspberries构建Boost.Fiber.

  • 我太快回复了...说实话,为了解决我身边的问题,我修补了Boost.Fiber构建jamfile并删除了所有要求.助推器从来没有回答过我,这是我克服这个问题的唯一途径.由于这个问题,无法构建Boost.Fiber,因为建筑系统只是拒绝这样做.你可以在这里看到我提交给OpenWRT的补丁https://github.com/openwrt/packages/pull/3510 (2认同)