Ubuntu uses gcc of different versions
Different Versions of ubuntu have different gcc, such as ubuntu 10.04 default gcc version is gcc-4.4.1, ubuntu 10.10gcc default version is gcc-4.4.5.
However, in actual use, we want to use other gcc compilers because of cross-compilation or other specific requirements. For example, if I want to use gcc-4.3 in ubuntu 10.10, what should I do?
First open the new software manager, enter gcc in it, find the gcc-4.3 and g ++-4.3, and then select:
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.3 30
Enter the following information on the terminal:
Sudo update-alternatives-config gcc
Terminal output:
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.3 30 manual mode
2/usr/bin/gcc-4.4 40 manual mode
Press enter to keep the current choice [*], or type selection number:
Here, I entered 1 because I want to use a gcc-4.3.
After performing this operation, enter gcc-v. The current gcc version is 4.3.5.
In the same way, change the g ++ version, open the new software manager, search for g ++-4.3, and select the relevant software.
Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/g ++-4.4 40
Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/g ++-4.3 30
Enter the following information on the terminal:
Sudo update-alternatives-config g ++
The terminal on my computer will output the following content:
There are 2 choices for the alternative g ++ (providing/usr/bin/g ++ ).
Selection Path Priority Status
------------------------------------------------------------
0/usr/bin/g ++-4.4 40 auto mode
* 1/usr/bin/g ++-4.3 30 manual mode
2/usr/bin/g ++-4.4 40 manual mode
Press enter to keep the current choice [*], or type selection number:
Select 1.
If g ++-v is also used, we can see that the version is 4.3.5.
Author: haiyangcqu