ubuntu 选择gcc 版本

来源:互联网 发布:win10下载哪个java jdk 编辑:程序博客网 时间:2024/05/29 21:16

http://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu


To figure out the current priorities of gcc, type in the command pointed out by @tripleee's comment:

查看当前的可切换的版本: update-alternatives --query gcc
例如有 4.6 4.5 两个版本
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 100update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.5 50update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 100update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.5 50update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.6 100update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.5 50
设置为4.5
update-alternatives --set g++ /usr/bin/g++-4.5update-alternatives --set gcc /usr/bin/gcc-4.5update-alternatives --set cpp-bin /usr/bin/cpp-4.5

Here, 4.6 is still the default (aka "auto mode"), but I explicitly switch to 4.5 temporarily (manual mode). To go back to 4.6:

update-alternatives --auto g++update-alternatives --auto gccupdate-alternatives --auto cpp-bin
方法二:
echo 'export CXX=/usr/bin/gcc-4.5' >> ~/.bashrc
移除当前的选择可以这样

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc sudo update-alternatives --remove-all g++
Install Packages

It seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages:

sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4

First erased the current update-alternatives setup for gcc and g++:

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

Install Packages

It seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages:

sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4
0 0
原创粉丝点击