阿里云深圳服务器 – 记录CentOS8升级gcc命令
目前的gcc版本是8, 计划是升级到11
1 2 3 4 5 6 7 8 9 10 |
# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) |
首先是现状描述
1 2 3 4 |
# yum install centos-release-scl Last metadata expiration check: 1:33:50 ago on Thu 09 Nov 2023 12:41:14 PM CST. No match for argument: centos-release-scl Error: Unable to find a match: centos-release-scl |
CentOS8使用的也不再是之前的 devtoolset 了
1 2 3 |
# yum search devtoolset Last metadata expiration check: 1:34:14 ago on Thu 09 Nov 2023 12:41:14 PM CST. No matches found. |
第一步是切换阿里云的yum源
1 2 3 4 5 6 7 8 9 10 11 |
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo --2023-11-09 14:17:22-- http://mirrors.aliyun.com/repo/Centos-8.repo Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 47.118.227.105, 47.118.227.104, 47.118.227.109, ... Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|47.118.227.105|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2590 (2.5K) [application/octet-stream] Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’ /etc/yum.repos.d/CentOS-Base.repo 100%[================>] 2.53K --.-KB/s in 0s 2023-11-09 14:17:22 (5.22 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2590/2590] |
第二步,可以查看当前可安装的 gcc-toolset 版本
1 |
# yum list | grep gcc-toolset |
这里我们直接选择最新的 gcc-11 进行安装
1 |
# yum install -y gcc-toolset-11 |
然后通过 source 命令启用gcc-11
1 |
# source /opt/rh/gcc-toolset-11/enable |
最后通过 gcc -v 命令查看当前的gcc版本号
1 2 3 4 5 6 7 8 9 10 11 |
# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-11/root/usr --mandir=/opt/rh/gcc-toolset-11/root/usr/share/man --infodir=/opt/rh/gcc-toolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20210728/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.1 20210728 (Red Hat 11.2.1-1) (GCC) |
OK 升级成功~
CentOS8 升级gcc版本
太感谢了,centos老版本不维护以后坑太多太多了