linux安装gcc命令步骤(centos安装gcc命令) |
您所在的位置:网站首页 › yum什么命令 › linux安装gcc命令步骤(centos安装gcc命令) |
>一、前言 本文介绍在CentOS7.8系统下使用YUM升级GCC版本的相关操作步骤。 CentOS7默认安装的gcc版本是4.8版本,gcc 4.8最主要的一个特性就是全面支持C++11,如果不清楚什么用的也没关系,简单说一些C++11标准的程序都需要gcc 4.8以上版本的gcc编译器编译。很多工具依赖的是更高版本的gcc,比如编译MySQL 8.0(8.0.16以上版本是C++14标准,需gcc 5.3以上版本)、Redis 6.0.x、GRPC等。手动编译升级gcc往往耗时长,而且不一定能成功,使用devtoolset 可以快速切换gcc版本。 采用CentOS的一个第三方库SCL(软件选集)的 devtoolset ,SCL可以在不覆盖原系统软件包的情况下安装新的软件包与老软件包共存并且可以使用scl命令切换,不过也有个缺点就是只支持64位的。 官网:https://gcc.gnu.org/ 源码包下载:http://ftp.gnu.org/gnu/gcc 特别说明: 目前第三方库SCL还没有gcc 11.x以上版本的YUM源,若要升级为11.x以上的版本需要通过源码编译安装。 第三方库SCL的devtoolset-6版本已经结束支持,只能通过源码编译安装升级gcc 6.x。 第三方库SCL的devtoolset-4及devtoolset-3版本(即gcc 5.x 和 4.9.2版本)已经结束支持,只能通过其他方法安装升级gcc 5.x 和 4.9.2。 若是在RHEL系统上升级GCC,安装第三方库SCL后需为系统启用RHSCL存储库,使用命令:yum-config-manager --enable rhel-server-rhscl-7-rpms 二、查看系统默认GCC版本 gcc -v
三、升级为10.2.1版本 ## 安装第三方SCL源仓库 yum -y install centos-release-scl ## 安装gcc 10.2.1 的版本 yum -y install devtoolset-10-gcc* 或 yum -y install devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-binutils ## 激活gcc 10.2.1 scl enable devtoolset-10 bash ## 验证 gcc -v
四、升级为9.3.1版本 ## 安装第三方SCL源仓库 yum -y install centos-release-scl ## 安装gcc 9.3.1 的版本 yum -y install devtoolset-9-gcc* 或 yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils ## 激活gcc 9.3.1 scl enable devtoolset-9 bash ## 验证 gcc -v
## 需要注意的是使用scl命令激活启用gcc只是临时的,退出当前shell环境或重启系统就会恢复为原来的gcc版本。若要想一直使用升级后的gcc版本,可配置系统环境变量,使用如下命令: echo \"source /opt/rh/devtoolset-9/enable\" >> /etc/profile source /etc/profile 五、升级为8.3.1版本 ## 安装第三方SCL源仓库 yum -y install centos-release-scl ## 安装gcc 8.3.1 的版本 yum -y install devtoolset-8-gcc* 或 yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils ## 激活gcc 8.3.1 scl enable devtoolset-8 bash ## 验证 gcc -v
## 需要注意的是使用scl命令激活启用gcc只是临时的,退出当前shell环境或重启系统就会恢复为原来的gcc版本。若要想一直使用升级后的gcc版本,可配置系统环境变量,使用如下命令: echo \"source /opt/rh/devtoolset-8/enable\" >> /etc/profile source /etc/profile 六、升级为7.3.1版本 ## 安装第三方SCL源仓库 yum -y install centos-release-scl ## 安装gcc 7.3.1 的版本 yum -y install devtoolset-7-gcc* 或 yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils ## 激活gcc 7.3.1 scl enable devtoolset-7 bash ## 验证 gcc -v
## 需要注意的是使用scl命令激活启用gcc只是临时的,退出当前shell环境或重启系统就会恢复为原来的gcc版本。若要想一直使用升级后的gcc版本,可配置系统环境变量,使用如下命令: echo \"source /opt/rh/devtoolset-7/enable\" >> /etc/profile source /etc/profile 七、升级为5.2.1版本 ## 安装软件源 wget -O /etc/yum.repos.d/hhorak-devtoolset-4-rebuild-bootstrap-epel-7.repo https://copr.fedorainfracloud.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-7/hhorak-devtoolset-4-rebuild-bootstrap-epel-7.repo 或 wget -O /etc/yum.repos.d/hhorak-devtoolset-4-rebuild-bootstrap-epel-7.repo https://copr.fedorainfracloud.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap2/repo/epel-7/hhorak-devtoolset-4-rebuild-bootstrap2-epel-7.repo yum makecache fast ## 安装gcc 5.2.1 的版本 yum -y install devtoolset-4-gcc* 或 yum -y install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-binutils ## 激活gcc 5.2.1 scl enable devtoolset-4 bash ## 验证 gcc -v
## 需要注意的是使用scl命令激活启用gcc只是临时的,退出当前shell环境或重启系统就会恢复为原来的gcc版本。若要想一直使用升级后的gcc版本,可配置系统环境变量,使用如下命令: echo \"source /opt/rh/devtoolset-4/enable\" >> /etc/profile source /etc/profile 八、升级为4.9.2版本 注:其实也没必要升级,CentOS7系统默认安装的是4.8.5,同为大版本4,功能作用应相差无几。 ## 安装软件源 wget -O /etc/yum.repos.d/rhscl-devtoolset-3-el7-epel-7.repo https://copr.fedorainfracloud.org/coprs/rhscl/devtoolset-3-el7/repo/epel-7/rhscl-devtoolset-3-el7-epel-7.repo yum makecache fast ## 安装gcc 4.9.2 的版本 yum -y install devtoolset-3-gcc* 或 yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-binutils ## 激活gcc 4.9.2 scl enable devtoolset-3 bash ## 验证 gcc -v
## 需要注意的是使用scl命令激活启用gcc只是临时的,退出当前shell环境或重启系统就会恢复为原来的gcc版本。若要想一直使用升级后的gcc版本,可配置系统环境变量,使用如下命令: echo \"source /opt/rh/devtoolset-3/enable\" >> /etc/profile source /etc/profile
本文内容由互联网用户自发贡献,该文观点仅代表作者本人。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至 [email protected] 本文链接:https://jinnalai.com/fenxiang/14337.html |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |