Change the default gccg ++ compiler version for Ubuntu

Source: Internet
Author: User
Upgrade Ubuntu to 11.10, but an error occurred while compiling Android. This Android system was compiled correctly before the upgrade. We found that the gcc and g ++ versions after the upgrade to Ubuntu11.10 were 4.6.1. The previous version is 4.4.6. I think most of the reason is here. To solve the problem, you need to change the default compiler version of Ubuntugcc and g ++. Google finds two methods to change. Method 1: First, check whether your Ubuntu is installed

Upgrade Ubuntu to 11.10, but an error occurred while compiling Android. This Android system is not compiled correctly before the upgrade. After the upgrade to Ubuntu 11.10, we found that gcc and g ++ versions are 4.6.1. The previous version is 4.4.6. I think most of the reason is here. To solve the problem, you need to change the Ubuntu gcc, g ++ default compiler version. Google finds two methods to change.

Method 1:

First, let's take a look at the gcc commands installed on your Ubuntu: ls/usr/bin/gcc *-l my display is

Lrwxrwxrwx 1 root 7/usr/bin/gcc-> gcc-4.6

-Rwxr-xr-x 1 root 224544 2011-10-06/usr/bin/gcc-4.4

-Rwxr-xr-x 1 root 237072/usr/bin/gcc-4.5

-Rwxr-xr-x 1 root 302104/usr/bin/gcc-4.6

From the above display we can see that the default installation is gcc-4.6, now to change to gcc-4.4

Delete the soft connection file/usr/bin/gcc for the gcc-4.6. (Just delete the soft connection)

Command: sudo rm/usr/bin/gcc

Then a soft connection points to the gcc-4.4.

Command: sudo ln-s/usr/bin/gcc-4.4/usr/bin/gcc

OK, www.linuxidc.com now uses the command: gcc-v to display the following:

Use built-in specs.

Goals: i686-linux-gnu

Configuration :.. /src/configure-v -- with-pkgversion = 'ubuntu/Linaro 4.4.6-11ubuntu2' -- with-bugurl = file: // usr/share/doc/gcc-4.4/README. bugs -- enable-languages ages = c, c ++, fortran, objc, obj-c ++ -- prefix =/usr -- program-suffix =-4.4 -- enable-shared -- enable-linker-build-id -- with-system-zlib -- libexecdir =/usr /lib -- without-included-gettext -- enable-threads = posix -- with-gxx-include-dir =/usr/include/c ++/4.4 -- libdir =/usr/lib -- enable-nls -- with-sysroot =/-- enable-clocale = gnu -- enable-libstdcxx-debug -- enable-objc-gc -- enable-targets = all -- disable-werror -- -arch-32 = i686 -- with-tune = generic -- enable-checking = release -- build = i686-linux-gnu -- host = i686-linux-gnu -- target = i686-linux-gnu

Thread model: posix

Gcc 4.4.6 (Ubuntu/Linaro 4.4.6-11ubuntu2)

Use the same method to change the default version of g ++.

Method 2:

Modify the default gcc and g ++ version to 4.4.

Sudo update-alternatives -- remove-all gcc

Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/gcc-4.4 40

Sudo update-alternatives -- install/usr/bin/g ++-4.4 40

Configure the default gcc and g ++

Sudo update-alternatives -- config gcc

Sudo update-alternatives -- config g ++

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.