Switch GCC, G ++, and gfortran versions in Ubuntu
Step 1: use which gcc, which g ++, and which gfortran to view the location. My result is/usr/bin/gcc; /usr/bin/g ++ and/usr/bin/gfortran
Part 2: first, let's take a look at the gcc commands installed in your Ubuntu: ls/usr/bin/gcc *-l;
Gcc/g ++ in ubuntu 12.04 is 4.6. We will downgrade the default system to 4.4.
$ Sudo apt-get install gcc-4.4
$ Sudo update-alternatives -- install/usr/bin/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/usr/bin/gcc-4.6 60
(The built-in priority is set to 60 and higher)
Select the default gcc
$ Sudo update-alternatives -- config gcc
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/bin/gcc-4.6 60 auto mode
1/usr/bin/gcc-4.4 40 manual mode
2/usr/bin/gcc-4.6 60 manual mode
The highest priority is used by default,
Select 1 here.
Next, perform the same steps in g ++.
$ Sudo apt-get install g ++-4.4
$ Sudo apt-get install g ++-4.4-multilib
$ Sudo update-alternatives -- install/usr/bin/g ++-4.4 40
$ Sudo update-alternatives -- install/usr/bin/g ++-4.6 60
$ Sudo update-alternatives -- config g ++
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/bin/g ++-4.6 60 auto mode
1/usr/bin/g ++-4.4 40 manual mode
2/usr/bin/g ++-4.6 60 manual mode
Select 1.
If you want to change to a later version
Update-alternatives -- config command switch!
Linux GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit edition as an example)
Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 and compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4
Install and use Vim + GCC + GDB in Ubuntu
Switch two GCC versions in Ubuntu
CentOS6.5 upgrade to manually install GCC4.8.2
GCC details: click here
GCC: click here