升级 gcc8.2.0
# 下载网址为 https://ftp.gnu.org/gnu
# 安装wget(已经是root)
yum install wget -y
# 安装make
[root@localhost root]# cd /home
[root@localhost home]# mkdir make
[root@localhost make]# wget https://ftp.gnu.org/gnu/make/make-4.3.tar.gz
[root@localhost make]# tar -zvxf make-4.3.tar.gz
[root@localhost make]# cd make-4.3
[root@localhost make-4.3]# ./configure
[root@localhost make-4.3]# make -j4
[root@localhost make-4.3]# make install
# 此时还是之前的make版本
[root@localhost make-4.3]# make --version
# 查找make位置
[root@localhost make-4.3]# whereis make
## 结果 make: /usr/bin/make /usr/local/bin/make /usr/share/man/man1/make.1.gz
#分别查看版本
[root@localhost make-4.3]# /usr/bin/make -v
[root@localhost make-4.3]# /usr/local/bin/make -v
#强制 记得backup旧软链
[root@localhost make-4.3]# ln -sf /usr/local/bin/make /usr/bin/make
# 成功将make3 升级为 make4.3
[root@localhost make-4.3]# make -v
#升级cmake
[root@localhost home]# mkdir cmake
[root@localhost home]# cd cmake/
[root@localhost cmake]# ls
[root@localhost cmake]# wget https://cmake.org/files/v3.21/cmake-3.21.0.tar.gz
[root@localhost cmake]# tar -zvxf cmake-3.21.0.tar.gz
# 安装必要库 OpenSSL
[root@localhost cmake]# yum -y install ncurses-devel
[root@localhost cmake]# yum install openssl-devel
[root@localhost cmake]# cd cmake-3.21.0
[root@localhost cmake-3.21.0]# ./configure --prefix=/usr/local/cmake
[root@localhost cmake-3.21.0]# make -j16&& make install
# 电脑本身没有cmake
[root@localhost cmake-3.21.0]# ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
GCC_V='8.2.0'
## sudo yum groupinstall chinese-support
# sudo yum install -y glibc-static libstdc++-static cmake
[root@localhost cmake-3.21.0]# yum install -y glibc-static
[root@localhost cmake-3.21.0]# yum install -y libstdc++-static
# wget http://ftp.gnu.org/gnu/gcc/gcc-${GCC_V}/gcc-${GCC_V}.tar.gz -O
[root@localhost home]# clear
[root@localhost home]# mkdir gcc
[root@localhost home]# cd gcc/
[root@localhost gcc]# wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz
[root@localhost gcc]# tar -zvxf gcc-8.2.0.tar.gz
[root@localhost gcc]# cd gcc-8.2.0
# ./contrib/download_prerequisites #安装一些依赖 安装失败了,报的错误为 Cannot download gmp-6.1.0.tar.bz2 from ftp://gcc.gnu.org/pub/gcc/infrastructure/
# 所以自己去网站下载 download_prerequisites里面所需要的的依赖库 gmp-6.1.0.tar.bz2 mpfr-3.1.4.tar.bz2 mpc-1.0.3.tar.gz isl-0.18.tar.bz2 放入到gcc-8.2.0
[root@localhost gcc-8.2.0]# ./contrib/download_prerequisites
[root@localhost gcc-8.2.0]# mkdir build
[root@localhost gcc-8.2.0]# cd build
[root@localhost build]# yum install texinfo
[root@localhost build]# ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
[root@localhost build]# make -j
[root@localhost build]# make install
[root@localhost build]# rm -rf /usr/bin/gcc
[root@localhost build]# ln -sf /usr/local/bin/gcc /usr/bin/gcc
[root@localhost build]# rm -rf /usr/lib64/libstdc++.so.6
[root@localhost build]# cp -rfp /usr/local/lib64/libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6.0.25
[root@localhost build]# ln -sf /usr/lib64/libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6
降级4.8.5过程
GCC_V='4.8.5'
[root@localhost gcc]# wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
[root@localhost gcc]# tar -zvxf gcc-8.2.0.tar.gz
[root@localhost gcc]# cd gcc-4.8.5
[root@localhost gcc-4.8.5]# ./contrib/download_prerequisites
[root@localhost gcc-4.8.5]# mkdir build
[root@localhost gcc-4.8.5]# cd build
### 如果需要完整替换整个gcc环境 需要改--prefix=/usr
[root@localhost build]# ../configure --prefix=/usr/local/gcc4.8.5 --enable-checking=release --enable-languages=c,c++ --disable-multilib
[root@localhost build]# make -j
[root@localhost build]# make install
# 中间出了不少问题 请看下方参考博客
[root@localhost build]# cp -rfp /usr/local/gcc4.8.5/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6.0.19
[root@localhost build]# cp -rfp /usr/local/gcc4.8.5/bin/gcc /usr/bin/gcc-4.8.5
[root@localhost build]# ln -sf /usr/bin/gcc-4.8.5 /usr/bin/gcc
[root@localhost build]# ln -sf /usr/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6
参考博客:https://blog.csdn.net/weixin_43730078/article/details/87967725
如果出现 这个问题 ,根据参考博客2的说明 修改cfns.gperf、cfns.h、except.c,之后清除gcc-4.8.5/build/* 所有文件之后重新 make操作,目前已经成功
cfns.gperf:101:1: error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attribute
参考博客2:https://blog.csdn.net/weixin_36023181/article/details/108292273
如果出现gcc版本仍然在高版本 用whereis gcc 查看gcc软链的位置不是在/usr/bin/gcc 而是在/usr/local/bin/gcc 或者其他目录 参考方式:用gcc --version查看版本a 然后 /usr/local/bin/gcc --version 查看版本是不是a 我的是上述的例子 所以我做了
ln -sf /usr/bin/gcc /usr/local/bin/gcc
之后就可以在gcc --version 查看到版本换为4.8.5
##################20210924####################
升级centos内核
[root@localhost ~]# yum update kernel
[root@localhost ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (3.10.0-1160.42.2.el7.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-5f1bf4f4b499420e9800a74e4a5a49de) 7 (Core)
[root@localhost ~]# grub2-set-default 0