我需要在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)的功能?
答案 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版本,但我认为它没有理由不起作用。
为了这个例子,我们假设:
/some/where/g++-5.4
/path/to/sources/of/boost-1.62.0/
/dest/path
现在:
zlib
,bzip2
,lzma
,zstd
,iconv
,{ {1}})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
(N是系统中的核心数)./b2 --toolset=gcc-5.4 -j N
注意:
./b2 install --prefix=/dest/path
替换为c++11
。如果您使用的是其他GCC版本,请记住在标准最终确定之前,您实际上并未获得其开关。因此,C ++ 11用于表示c++1y
和C ++ 17为--std=c++1x
,并且随着GCC版本在标准最终确定后发布,开关也会发生变化。答案 1 :(得分:7)