title: 76.升级gcc版本 CreateTime: 2022-05-19 11:00:00 UpdateTime: 2025-06-06 11:23:09 CategoryName: Web --- --- title: "76.升级gcc版本" date: 2022-05-19T11:00:00+08:00 draft: false tags: ["web"] categories: ["web"] author: "springrain" --- CentOS7 默认gcc版本为4.8,有时需要更高版本,这里以升级至11.2.1版本为例,分别执行下面三条命令即可,无需手动[下载源码](http://ftp.gnu.org/gnu/gcc/)编译 ```shell ##安装centos-release-scl yum install centos-release-scl ##安装devtoolset,如果想安装8.*版本的,就改成devtoolset-8-gcc*,以此类推 yum install devtoolset-10-gcc* ##激活对应的devtoolset,所以你可以一次安装多个版本的devtoolset,需要的时候用下面这条命令切换到对应的版本 scl enable devtoolset-10 bash ##大功告成,查看一下gcc版本 gcc -v ##装的devtoolset在 /opt/rh 目录,每个版本的目录下面都有个 enable 文件,如果需要启用某个版本,只需要执行 source /opt/rh/devtoolset-10/enable ##旧的gcc是运行的 /usr/bin/gcc,所以将该目录下的gcc/g++替换为刚安装的新版本gcc软连接,免得每次enable mv /usr/bin/gcc /usr/bin/gcc-4.8.5 ln -s /opt/rh/devtoolset-10/root/bin/gcc /usr/bin/gcc mv /usr/bin/g++ /usr/bin/g++-4.8.5 ln -s /opt/rh/devtoolset-10/root/bin/g++ /usr/bin/g++ gcc --version g++ --version ``` 升级make ```shell ##下载 wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz tar -xvf make-4.3.tar.gz cd make-4.3 mkdir build && cd build ##执行 ../configure --prefix=/usr ##执行完,这里需要编译,会生成build.sh文件,然后执行这个文件 #sh build.sh ##然后安装 make install ##然后就安装完成了,查看版本 make -v ``` 升级cmake ```shell yum install -y openssl-devel libxml2 libxml2-devel bzip2 bzip2-devel curl libcurl-devel wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz tar -zxvf cmake-3.28.3.tar.gz cd cmake-3.28.3 ./bootstrap --prefix=/usr make -j$(nproc) make install ``` CentOS 7 ARM 架构升级GCC 修改```CentOS-SCLo-sclo.repo``` ``` # CentOS-SCLo-sclo.repo # # Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more # information [centos-sclo-sclo] name=CentOS-7 - SCLo sclo baseurl=https://mirrors.aliyun.com/centos-altarch/7/sclo/aarch64/sclo/ gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo [centos-sclo-rh] name=CentOS-7 - SCLo rh baseurl=https://mirrors.aliyun.com/centos-altarch/7/sclo/aarch64/rh/ gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo ```