centos 7安装新版本 gcc
centos 7 安装 gcc 和 g++ 的命令分别如下:yum install gccyum install gcc-c++但是安装的版本是:(GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)安装更高版本的 gcc 有两种方式这里以 gcc 7.3 为例1. 手动编译具体步骤参考:build gcc from source on centos 7可以编译成功,也可以
centos 7 安装 gcc 和 g++ 的命令分别如下:
yum install gcc
yum install gcc-c++
但是安装的版本是:
(GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
安装更高版本的 gcc 有两种方式
这里以安装 gcc 7.3 为例
1. 手动编译
具体步骤参考:build gcc from source on centos 7
可以编译成功,一般情况下也可以正常使用。
但是在有些编译中会出现 gcc 版本引用不正确的情况。所以不推荐。
2. 使用 SCL 软件管理
SCL 介绍如下:
Software Collections , also known as SCL is a community project that allows you to build, install, and use multiple versions of software on the same system, without affecting system default packages. By enabling Software Collections, you gain access to the newer versions of programming languages and services which are not available in the core repositories.
The SCL repositories provide a package named Developer Toolset, which includes newer versions of the GNU Compiler Collection, and other development and debugging tools.
步骤
- 更新
yum update -y
- 安装 SCL 发行包
centos-release-scl
yum install -y centos-release-scl
- 安装需要的Software Collection。
yum install -y devtoolset-7-gcc*
- 使用已安装的软件集合环境。
此时gcc版本是:(GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)scl enable devtoolset-7 bash
- 退出当前环境。回退到原来的gcc环境。
exit
官网查询目前有三个版本,可以修改以上步骤安装所需版本:
- devtoolset-8
- devtoolset-7
- devtoolset-6
参考:
更多推荐
所有评论(0)