Change Ubuntu gcc, g++ default compiler version

Source: Internet
Author: User
Tags posix

Method One:

First, take a look at what versions of GCC you have installed in your Ubuntu command: ls/usr/bin/gcc*-L My display is

lrwxrwxrwx 1 root root 7 2011-08-14 15:17/USR/BIN/GCC-gcc-4.6

-rwxr-xr-x 1 root root 224544 2011-10-06 05:47/usr/bin/gcc-4.4

-rwxr-xr-x 1 root root 237072 2011-09-17 17:25/usr/bin/gcc-4.5

-rwxr-xr-x 1 root root 302104 2011-09-17 05:43/usr/bin/gcc-4.6

As shown above, you can see that the default installation is gcc-4.6, which is now changed to gcc-4.4

Delete the gcc-4.6 soft connection file/USR/BIN/GCC. (just remove the soft connection)

Command: sudo rm/usr/bin/gcc

Then build a soft connection that points to the gcc-4.4.

Command: sudo ln-s/USR/BIN/GCC-4.4/USR/BIN/GCC

OK, www.linuxidc.com now with the command: Gcc-v display as follows:

Use built-in specs.

Target: I686-linux-gnu

Configured as:.. /src/configure-v--with-pkgversion= ' Ubuntu/linaro 4.4.6-11ubuntu2 '--with-bugurl=file:///usr/share/doc/gcc-4.4/ Readme. Bugs--enable-languages=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--with-arch-32=i686--with-tune= Generic--enable-checking=release--build=i686-linux-gnu--host=i686-linux-gnu--target=i686-linux-gnu

Threading Model: POSIX

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

Change the default version of g++ in the same way.

Method Two:

Modify the default GCC and g++ versions of 4.4

sudo update-alternatives--remove-all gcc

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

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

Configuring the default GCC and g++

sudo update-alternatives--config gcc

sudo update-alternatives--config g++

Change Ubuntu gcc, g++ default compiler version

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.