【问题标题】:Building Boost 1.75 Issue in CentOS7 with an Already Installed C++11 Compiler使用已安装的 C++11 编译器在 CentOS7 中构建 Boost 1.75 问题
【发布时间】:2021-06-05 09:23:07
【问题描述】:

我正在尝试在 CentOS7 中构建boost 1.75。

gccC++ 分别使用以下 shell 脚本更新到版本 9.3.1 和 c++14。

script_update_gcc.sh

sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-9-gcc*
source scl_source enable devtoolset-9
gcc --version
# gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

script_update_c++.sh

sudo yum -y install centos-release-scl-rh
sudo yum-config-manager --enable centos-release-scl-rh
sudo yum -y install devtoolset-9
source scl_source enable devtoolset-9

我用来从源代码构建boost 的脚本如下。

wget https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz
tar -xzf boost_1_75_*
cd boost_1_75_*
sudo ./bootstrap.sh --prefix=/opt/boost 
sudo ./b2 install --prefix=/opt/boost --with=all

但是,我收到以下错误消息

A C++11 capable compiler is required for building the B2 engine.
Toolset 'cxx' does not appear to support C++11.

** Note, the C++11 capable compiler is _only_ required for building the B2
** engine. The B2 build system allows for using any C++ level and any other
** supported language and resource in your projects.


You can specify the toolset as the argument, i.e.:
    ./build.sh gcc

Toolsets supported by this script are:
    acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,
    pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp

我尝试了./build.sh gcc,但文件没有在源文件夹中存在。我还尝试将gcc 版本添加到也不起作用的boostrap。

sudo ./bootstrap.sh --prefix=/opt/boost --with-toolset=gcc-9.3.1

作为我最后的手段,我尝试了clang,但它也没有帮助,并给了我与上面完全相同的错误:

./bootstrap.sh toolset=clang cxxflags="-stdlib=libc++ -std=c++11" linkflags="-stdlib=libc++"

有人可以帮我吗?我已经将c++gcc 更新到了最新版本,我不知道为什么boost 抱怨没有支持c++11 的编译器。

【问题讨论】:

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


    【解决方案1】:

    您额外的“script_update_c++.sh”将 gcc 4.8 安装到 /usr/bin。我认为这可能会造成干扰。

    试试

    hash -r
    which gcc
    gcc --version
    

    (还有哪个g++)来找出你的路径正在拾取什么。

    如果它报告 GCC 4.8,那么您很可能只是在子 shell 中执行脚本,而不是采购它们。那是行不通的,因为

    source scl_source enable devtoolset-9
    

    当前 shell 设置环境变量。因此,要么自行发布,要么通过采购脚本来运行脚本。

    【讨论】:

    • 对于演示Download这个gist使用docker build .进行测试
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    • 2013-08-10
    • 1970-01-01
    • 2021-01-02
    • 2022-10-14
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多