1、安装 gcc
yum install-y gcc-c++ autoconf automake
2、升级gcc编译器版本
yum -yinstall centos-release-scl
yum -yinstall devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-009-binutils
scl enable devtoolset-9 bash3、scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本,若要固定版本,需要添加环境变量
echo"source /opt/rh/devtoolset-9/enable">>/etc/profile
4、查看当前gcc版本
[root@localhost bin]# gcc --version
gcc (GCC)9.3.1 20200408(Red Hat 9.3.1-2)
Copyright (C)2019 Free Software Foundation, Inc.
This is free software; see the sourcefor copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.