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 100
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.5 50
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 100
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.5 50
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.6 100
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.5 50设置为4.5update-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 gcc
update-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 PackagesIt 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 |
|---|