Install GCC

yum install gcc
yum install gcc-c++
Copy the code

Upgrade GCCX 7.0.x.x

PS: Do not use older versions of GCC to compile younger versions of GCC.

wget https://ftp.gnu.org/gnu/gcc/gcc-x.x.x.... tar -xzvf gcc-x.x.x.tar.gz cd gcc-x.x.x ./contrib/download_prerequisites mkdir build cd build .. /configure --prefix=/usr/local/gccx.x.x --enable-checking=release --enable-languages=c,c++ --disable-multilib make -j4 make install gcc -vCopy the code

Find all GCC versions

find /usr -name gcc  
Copy the code

Switching GCC versions

Gcc-9.3.0 is installed in /usr/bin/. Other versions of GCC are installed in /usr/local/gccx.xx/.

9.3.0 to 4.8.5 mkdir -p /usr/local/bin/gcc-9.3.0mv /usr/bin/gcc /usr/local/bin/gcc-9.3.0/ln -s / usr/local/gcc4.8.5 / bin/GCC/usr/bin/GCC mkdir -p/usr/local/bin/g + + - 9.3.0 mv/usr/bin/g + + / usr/local/bin/g + + - 9.3.0 / ln - s/usr/local/gcc4.8.5 / bin/g + + / usr/bin/g + + mkdir -p/usr/local/bin/c + + - 9.3.0 mv/usr/bin/c + + / usr/local/bin/c + + - 9.3.0 / Ln -s/usr/local/gcc4.8.5 / bin/c + + / usr/bin/c + + 4.8.5 to 9.3.0 mkdir -p/usr/local/bin/GCC - 4.8.5 mv/usr/bin/GCC /usr/local/bin/gcc-4.8.5/mv /usr/local/bin/gcc-9.3.0/gcc /usr/bin/gcc mkdir -p /usr/local/bin/g++ -4.8.5/mv The/usr/bin/g + + / usr/local/bin/g + + - 4.8.5 / mv/usr/local/bin/g + + - 9.3.0 / g + + / usr/bin/g + + mkdir -p/usr/local/bin/c + + - 4.8.5 Mv/usr/bin/c + + / usr/local/bin/c + + - 4.8.5 / mv/usr/local/bin/c + + - 9.3.0 / c + + / usr/bin/c + +Copy the code