-
gcc -v查看当前版本
-
安装需要的版本
#
sudo apt-get insall gcc-x
sudo apt-get insall gcc-x-multilib
sudo apt-get insall g++-x
sudo apt-get insall g++-x-multilib
- 更新优先级
#其中/usr/bin/gcc-x为版本所在的位置
#NUM为设置的优先级 100 为最大优先级
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-x NUM
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-x NUM
- ubuntu18.04安装gcc4.4.7(用于android编译)
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo apt install gcc-4.4
sudo apt install g++-4.4
sudo apt install gcc-4.4-multilib
sudo apt install g++-4.4-multilib
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 80
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 80