参考:
GLIBCXX_3.4.21' not found问题小记_wiggens的博客-CSDN博客
CentOS7升级GCC版本,解决version `GLIBCXX_3.4.21‘ not found_那一片海的博客-CSDN博客
Centos 7 升级 Glibc-2.28-腾讯云开发者社区-腾讯云
OSError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by xxx.so) ——升级GLIBC并解决系统错误 - 知乎
yum install -y centos-release-scl
yum install -y bison devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
scl enable devtoolset-8 bash
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
更新make
wget https://ftp.gnu.org/gnu/make/make-4.3.tar.gz
tar zxvf make-4.3.tar.gz
cd make-4.3 && ./configure --prefix=/data/local/make-4.3 && make && make install
mv /usr/bin/make /usr/bin/make.bak && ln -s /data/local/make-4.3/bin/make /usr/bin/make
安装glibc
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz
xz -d glibc-2.28.tar.xz && tar xvf glibc-2.28.tar && cd glibc-2.28
#也可以用-with-binutils=/opt/rh/devtoolset-8/root/usr/bin
mkdir build && cd build && ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --disable-sanity-checks --disable-werror
--enable-obsolete-nsl
make
sed -i '128i\ && $name ne "nss_test2"' ../scripts/test-installation.pl
make install
strings /usr/lib64/libc.so.6 | grep ^GLIBC
安装gcc,换用跟glibc-2.28发布时间差不多的版本gcc-8.3.0
wget https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz
xz -d gcc-12.3.0.tar.xz && tar xvf gcc-12.3.0.tar && cd gcc-12.3.0
wget https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.2.1.tar.bz2
wget https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-4.1.0.tar.bz2
wget https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.2.1.tar.gz
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2
tar jxvf gmp-6.2.1.tar.bz2 && tar jxvf mpfr-4.1.0.tar.bz2 && tar zxvf mpc-1.2.1.tar.gz && tar jxvf isl-0.24.tar.bz2
cd gmp-6.2.1 && ./configure && make && make install && cd ..
cd mpfr-4.1.0 && ./configure && make && make install && cd ..
cd mpc-1.2.1 && ./configure && make && make install && cd ..
cd isl-0.24 && ./configure && make && make install && cd ..
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig -v
mkdir build && cd build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make && make install