First step: Using which gcc, which g++, and which gfortran to view the location, my display results are:/usr/bin/gcc;/usr/bin/g++ and/usr/bin/gfortran
Part Two: First, take a look at what version of GCC you have installed in your Ubuntu command: ls/usr/bin/gcc*-L;
The gcc/g++ in Ubuntu 12.04 are all 4.6, and we downgrade the system to 4.4 by default.
$sudo Apt-get Install gcc-4.4
$sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-4.4 40
(Here "40" is the priority, the higher the value the higher the priority)
$sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-4.6 60
(This machine comes with a setting of 60 higher priority)
Select the system default GCC
$sudo update-alternatives--config gcc
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/bin/gcc-4.6 Auto mode
1/usr/bin/gcc-4.4 Manual Mode
2/usr/bin/gcc-4.6 Manual Mode
The default system with the highest priority,
We're going to choose 1 here.
Next, g++ the same steps
$sudo Apt-get Install g++-4.4
$sudo Apt-get Install G++-4.4-multilib
$sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.4 40
$sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.6 60
$sudo update-alternatives--config g++
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/bin/g++-4.6 Auto mode
1/usr/bin/g++-4.4 Manual Mode
2/usr/bin/g++-4.6 Manual Mode
Select 1.
If you want to change to a higher version of the ready
Update-alternatives--config command Switch!
Ubuntu under GCC, g++ and Gfortran version switching