使用(自定义)GCC 4.x或5.x时,Boost构建失败C ++ 11功能检查 [英] Boost build fails C++11 feature checks when using (custom) GCC 4.x or 5.x
问题描述
我需要在Fedora 24计算机上构建Boost 1.62和1.63,但使用GCC 4.9.3或GCC 5.4.0(取决于CUDA的版本,这就是为什么我需要更老的编译器的原因)。但是,如果我按照此答案中所述设置了自定义GCC版本并运行了
/ b2 --toolset = gcc-5.4.0阶段
$ b $我现在看到:
- 32位:no
- 64位:yes
- arm:no
- mips1:no
- power:no
- sparc:no
- x86:yes
- 支持的符号链接:是
- C ++ 11 mutex:no
- lockfree boost :: atomic_flag:是
- Boost.Config功能检查:cxx11_auto_declarations:no
- Boost.Config功能检查: cxx11_constexpr:no
- Boost.Config功能检查:cxx11_defaulted_functions:no
- Boost.Config功能检查:cxx11_final:是
- Boost.Config功能检查:cxx11_hdr_tuple:否
- Boost.Config功能检查:cxx11_lambdas:no
- Boost.Config功能检查:cxx11_noexcept:no
- Boost.Config功能检查:cxx11_nullptr:no
- Boost.Config功能检查:cxx11_rvalue_references:no
- Boost.Config功能检查:cxx11_template_aliases:no
- Boost.Config功能检查:cxx11_thread_local:no
- Boost.Config功能检查:cxx11_variadic_templates:是
即很多C ++ 11功能都被认为是错过了,而他们不应该这样做。这在使用发行版的GCC版本(6.2.1)构建时不会发生。
为什么会发生这种情况,我该怎么做才能让Boost build识别我的GCC 5.4.0(或4.9.3)的功能是什么?
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 /boost-1.62.0/sources/
- (也许)您想要将Boost安装到
/ dest / path $ c
$ b现在:
-
cd /path/to/boost-1.62.0/sources/$
- 通过运行
来增强构建系统的性能./ bootstrap.sh
echousing 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 5.4.0的(未完成的)C ++ 14支持,如果你使用的是不同的GCC版本,你可以使用code>c ++ 11
c ++ 1y
,请记住,在一个标准完成之前,你并没有真正得到它的开关,因此C ++ 11用来表示- std = c ++ 1x
和C + +17是- std = c ++ 1z
并且开关随着GCC版本在标准最终化后发布而变化 - 您可以替换
I need to build Boost 1.62 and 1.63 on a Fedora 24 machine, but using GCC 4.9.3 or GCC 5.4.0 (depending on the version CUDA, which is the reason why I need an older compiler). But if I set the custom GCC version as described in this answer and run
/b2 --toolset=gcc-5.4.0 stage
To my chagrin, I now see:
- 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
i.e. a lot of C++11 features are supposedly missing, while they should not be. This does not occur when building it with the distribution's GCC version (6.2.1).
Why is this happening and what should I do to make the Boost build recognize my GCC 5.4.0 (or 4.9.3)'s capabilities?
解决方案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.
Let's assume for the sake of this example that:
- You want to build Boost with GCC 5.4
- The g++ 5.4 binary is at
/some/where/g++-5.4
- You've downloaded and unpacked the Boost sources are at
/path/to/boost-1.62.0/sources/
- (Perhaps) you want to install Boost to
/dest/path
- You have N cores (so you want to parallelize the build N-ways)
Now:
cd /path/to/boost-1.62.0/sources/
- Booststrap the build system by running
./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
(replace N with the number of cores on your systems- (Assuming you want to install the built version:)
./b2 install --prefix=/dest/path
Notes:
- The order of actions 2 and 3 doesn't matter.
- You can replace
c++11
withc++1y
if you want GCC 5.4.0's (non-finalized) C++14 support. If you're using a different GCC version, remember that before a standard is finalized you don't actually get its switch available. Thus C++11 used to mean--std=c++1x
and C++17 was--std=c++1z
and the switches change as GCC versions get released after standard finalization.
这篇关于使用(自定义)GCC 4.x或5.x时,Boost构建失败C ++ 11功能检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-