Install and use gcc of different versions in ubuntu

Source: Internet
Author: User
Ubuntu uses different versions of gccubuntu system different versions have different gcc, such as ubuntu10.04 default gcc version is gcc-4.4.1, ubuntu10.10gcc default version is gcc-4.4.5. but in actual use, because of cross-compilation or other specific requirements, we...

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.