centos7安装、升级、切换gcc

安装gcc

yum install gcc yum install gcc-c++

升级gccx.x.x
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-languages=c,c++ --disable-multilib make -j4 make install gcc -v

查找所有gcc版本
find /usr -name gcc

切换gcc版本
to 4.8.5 mkdir -p /usr/local/bin/gcc-9.3.0 mv /usr/bin/gcc /usr/local/bin/gcc-9.3.0/ ln -s /usr/local/gcc4.8.5/bin/gcc /usr/bin/gccmkdir -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++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/gccmkdir -p /usr/local/bin/g++- 4.8.5 mv /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++to 8.2.0 mkdir -p /usr/local/bin/gcc-4.8.5 mv /usr/bin/gcc /usr/local/bin/gcc-4.8.5/ ln -s /usr/local/gcc8.2.0/bin/gcc/usr/bin/gccmkdir -p /usr/local/bin/g++-4.8.5 mv /usr/bin/g++ /usr/local/bin/g++-4.8.5/ ln -s /usr/local/gcc8.2.0/bin/g++/usr/bin/g++mkdir -p /usr/local/bin/c++-4.8.5 mv /usr/bin/c++ /usr/local/bin/c++-4.8.5/ ln -s /usr/local/gcc8.2.0/bin/c++/usr/bin/c++

    推荐阅读