Linux完美解决Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
问题描述:
Linux安装cmake,执行./bootstrap出现 Error when bootstrapping CMake: Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
解决方案:
问题分析:
查看gcc g++ 版本:gcc --version 发现是4.8.5(centos7系统自带的原始版本),这个版本不适配C++11的Cmake编译,因此需要升级gcc、g++版本。
然而根据网上那些教程直接 yum install gcc gcc-c++ 是无法升级cmake,版本仍然是4.8.5
因此需要采用scl 安装devtoolset,不推荐源码安装!!!一堆的问题!!!
具体操作:
1、安装centos-release-scl:
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm
2、安装devtoolset:
根据需求安装不同版本
sudo yum install devtoolset-9-gcc-c++
3、激活对应的devtoolset:
按理来说你可以一次安装多个版本的devtoolset,需要的时候用下面这条命令切换到对应的版本
scl enable devtoolset-9 bash
4、验证安装
gcc --version
遇到问题:
1、OpenGL未安装:CMake Error at /root/anaconda3/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message): Failed to find “GL/gl.h” in …
解决:
yum install -y mesa*
yum install -y freeglut*
yum install -y glew
2、待更新
在Linux(CentOS7)中安装CMake时遇到错误,由于系统自带的gcc/g++版本4.8.5不支持C++11。为解决此问题,需要通过安装devtoolset来升级gcc/g++,具体步骤包括安装centos-release-scl,使用yum安装devtoolset-9-gcc-c++,然后通过sclenabledevtoolset-9bash激活新版本。在过程中可能还会遇到OpenGL相关库缺失的问题,需安装mesa、freeglut和glew。
1万+

被折叠的 条评论
为什么被折叠?



