ubuntu gcc 降级和升级

时间:2021-11-20 02:24:19
方法基本一样:

先清除原来的版本:

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++


安装指定版本

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 48 \

--slave /usr/bin/g++ g++ /usr/bin/g++-4.8 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-4.8 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-4.8 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-4.8


配置更改:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++


查看修改完的版本:

gcc --version

gcc (Ubuntu/Linaro X.X.X-1ubuntu1~14.04) X.X.X

Copyright (C) 20XX Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


g++ --version

g++ (Ubuntu/Linaro X.X.X-1ubuntu1~14.04) X.X.X

Copyright (C) 20XX Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.