Ubuntu next two versions of GCC switch

Source: Internet
Author: User

The version of GCC used in Ubuntu is different from the release version, and when compiling the Android system different versions are recommended to compile with different gcc, so can you change the system's GCC to suit the needs of the Android build environment? The answer is yes.

Let's see what the GCC and g++ are for our system.

Gcc-v

The information you can get is as follows

GCC version 4.4.6 (Ubuntu/linaro 4.4.6-11ubuntu2)

What if we want to use gcc4.5? First see if there is gcc4.5 installed,

ls/usr/bin/gcc*

Results only/usr/bin/gcc/usr/bin/gcc-4.4 Two, then we need to install

sudo apt-get install gcc-4.5 gcc-4.5-multilib g++-4.5 g++-4.5-multilib

After installation, enter the following command:

sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.4 50

sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-4.5 40

Then enter:

sudo update-alternatives--config gcc

You will see the following options

There are 3 candidates that can be used to replace GCC (provides/USR/BIN/GCC).

Select Path Priority state
------------------------------------------------------------
* 0/usr/bin/gcc-4.4 50 Auto mode
1/usr/bin/gcc-4.4 50 Manual Mode
2/usr/bin/gcc-4.5 40 Manual Mode
3/usr/bin/gcc-4.6 30 Manual Mode

To maintain the current value [*], press ENTER, or type the number you selected:

If you want to use which GCC, enter the number.

Also set the g++

sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.4 50

sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.5 40

If you want to delete the optional option, you can type the following command:

sudo update-alternatives--remove gcc/usr/bin/gcc-4.5

Then use GCC-V to see if the version has changed.

Ubuntu next two versions of GCC switch

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.