关于linux:centos7安装升级切换gcc

32次阅读

共计 1346 个字符,预计需要花费 4 分钟才能阅读完成。

装置 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/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++

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 /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/gcc

mkdir -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++

正文完
 0