In Ubuntu10.04, the default GCC version is GCC4.4.1. Most of the time, we need to use GCC4.1.2. Therefore, we need to install the earlier version of GCC4.1.2. However, I tried to install GCC with version 4.1 and the final version is 4.1.3. It seems that it can be used as well. If you have better ideas, please follow the steps below: first install GCC4.1sudoapt-get Through apt-get
In Ubuntu 10.04, the default GCC version is GCC 4.4.1. Most of the time, we need to use GCC4.1.2, so we need to install the earlier version of GCC 4.1.2. However, I tried to install GCC with version 4.1 and the final version is 4.1.3. It seems that it can be used as well. If you have better ideas, please follow the steps below:
First install GCC4.1 through apt-get
- Sudo apt-get install gcc-4.1
After installation, there are two GCC versions 4.4 and 4.1 In the system. You can run the ls command to view them:
- Ls/usr/bin/gcc *
- /Usr/bin/gcc-4.1/Usr/bin/gcc-4.4/Usr/bin/gccbug-4.1
However, the default GCC version is 4.4. You can use gcc-v to view the version number.
Set the options of GCC4.1 and GCC4.4. Enter the following command on the terminal:
- Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/gcc-4.4 40
- Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/gcc-4.1 30
Set the default GCC version. Run the following command:
Sudo update-alternatives -- config gcc
Result:
There are 2 choices for the alternative gcc (providing/usr/bin/gcc ).
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/bin/gcc-4.4 40 auto mode
1/usr/bin/gcc-4.1 30 manual mode
2/usr/bin/gcc-4.4 40 manual mode
Enter "1" and check that the gcc version has changed to 4.1 ~~~~
You can also use the same method to switch from a later version of 4.4 to a later version of 4.1...
Of course you also need to switch i486-linux-gnu-gcc and i486-linux-gnu-g ++ to 4.1
The entire switchover script is as follows:
- #! /Bin/sh
- Update-alternatives -- install/usr/bin/gcc-4.4 40
- Update-alternatives -- install/usr/bin/gcc-4.1 30
- Update-alternatives -- config gcc
- Update-alternatives -- install/usr/bin/g ++-4.4 40
- Update-alternatives -- install/usr/bin/g ++-4.1 30
- Update-alternatives -- config g ++
- Update-alternatives -- install/usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc/usr/bin/i486-linux-gnu-gcc-4.4 40
- Update-alternatives -- install/usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc/usr/bin/i486-linux-gnu-gcc-4.1 30
- Update-alternatives -- config i486-linux-gnu-gcc
- Update-alternatives -- install/usr/bin/i486-linux-gnu-g + + i486-linux-gnu-g + +/usr/bin/i486-linux-gnu-g + +-4.4 40
- Update-alternatives -- install/usr/bin/i486-linux-gnu-g + + i486-linux-gnu-g + +/usr/bin/i486-linux-gnu-g + +-4.1 30
- Update-alternatives -- config i486-linux-gnu-g ++