以GCC9.2为例,下面是一个完整的下载源代码,编译,安装,配置的过程
cd /usr/local/src
wget ftp://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz
xz -d gcc-9.2.0.tar.xz
tar -xf gcc-9.2.0.tar
cd gcc-9.2.0
./configure --disable-multilib --enable-languages=c,c++ --prefix=/usr/local/gcc-9.2.0
make -j4
make -j install
mv /usr/bin/gcc /usr/bin/gcc.bak
mv /usr/bin/g++ /usr/bin/g++.bak
mv /usr/local/bin/gcc /usr/local/bin/gcc.bak
mv /usr/local/bin/g++ /usr/local/bin/g++.bak
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s /usr/local/gcc-9.2.0/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-9.2.0/bin/g++ /usr/bin/g++
ln -s /usr/local/gcc-9.2.0/bin/gcc /usr/local/bin/gcc
ln -s /usr/local/gcc-9.2.0/bin/g++ /usr/local/bin/g++
ln -s /usr/local/gcc-9.2.0/lib64/libstdc++.so.6.0.27 /usr/lib64/libstdc++.so.6
hash -r
--end--
标签:bin,gcc,++,GCC,usr,Linux,local,替换,9.2 From: https://www.cnblogs.com/math/p/18010377/source-build-install-config-gcc