环境:centos 7
1、准备开发环境
$ yum groupinstall "Development Tools" $ yum install glibc-static libstdc++-static
2、下载源码
wget http://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.gz
3、编译
tar -zxvf gcc-11.2.0.tar.gz cd gcc-11.2.0.tar.gz ./contrib/download_prerequisites mkdir build ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib make make install
4、检查版本
gcc -v strings /usr/lib64/libstdc++.so.6 | grep GLIBC