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 on Ubuntu: ls/usr/bin/gcc *-l; gcc/g ++ in ubuntu 12.04 is 4.6, we 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, higher value priority) $ sudo update-alternatives -- install/usr/bin/gcc/usr/bin/gcc-4.6 60 (comes To 60 higher priority) select the default gcc $ sudo update-alternatives -- config gcc Selection Path Priority Status failed * 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 default system with the highest priority, here we can select 1. Next, g ++ perform the same procedure $ sudo apt-get install g ++-4.4 $ sudo apt-get install g ++-4.4-multilib $ sudo update-alternatives -- inst All/usr/bin/g ++-4.4 40 $ sudo update-alternatives -- install/usr/bin/g ++ +/usr/bin/g ++-4.6 60 $ sudo update-alternatives -- config g ++ Selection Path Priority Status limit * 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, use the update-alternatives-config command to switch!