Switch GCC, G ++, and gfortran versions in Ubuntu

Source: Internet
Author: User
Step 1: Use whichgcc, whichg ++, and whichgfortran to view the position. My result is/usr/bin/gcc; /usr/bin/g ++ and/usr/bin/gfortran Part 2: first, let's take a look at the gcc commands installed on Ubuntu: ls/usr/bin/gcc *-l; the gcc/g ++ in ubuntu12.04 is 4.6, And we will downgrade the system to 4.4 by default.

Step 1: use which gcc, which g ++, and which gfortran to view the location. My result is/usr/bin/gcc; /usr/bin/g ++ and/usr/bin/gfortran

Part 2: first, let's take a look at the gcc commands installed in your Ubuntu: ls/usr/bin/gcc *-l;

Gcc/g ++ in ubuntu 12.04 is 4.6. We will downgrade the default system to 4.4.

$ Sudo apt-get install gcc-4.4

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

(Here "40" is the priority. The higher the value, the higher the priority)

$ Sudo update-alternatives -- install/usr/bin/gcc/usr/bin/gcc-4.6 60

(The built-in priority is set to 60 and higher)

Select the default gcc

$ Sudo update-alternatives -- config gcc

Selection Path Priority Status

------------------------------------------------------------

* 0/usr/bin/gcc-4.6 60 auto mode

1/usr/bin/gcc-4.4 40 manual mode

2/usr/bin/gcc-4.6 60 manual mode

The highest priority is used by default,

Select 1 here.

Next, perform the same steps in g ++.

$ Sudo apt-get install g ++-4.4

$ Sudo apt-get install g ++-4.4-multilib

 

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

$ Sudo update-alternatives -- install/usr/bin/g ++-4.6 60

$ Sudo update-alternatives -- config g ++

Selection Path Priority Status

------------------------------------------------------------

* 0/usr/bin/g ++-4.6 60 auto mode

1/usr/bin/g ++-4.4 40 manual mode

2/usr/bin/g ++-4.6 60 manual mode

Select 1.

If you want to change to a later version

Update-alternatives -- config command switch!

Linux upgrade GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit edition as an example) http://www.linuxidc.com/Linux/2014-04/99583.htm

Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 and compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4

Install and use http://www.linuxidc.com/Linux/2013-01/78159.htm with Vim + GCC + GDB in Ubuntu

Two GCC versions under Ubuntu switch http://www.linuxidc.com/Linux/2012-10/72284.htm

CentOS6.5 upgrade manual installation GCC4.8.2 http://www.linuxidc.com/Linux/2015-01/112595.htm

GCC details: Click here
GCC: Click here

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-09/123461.htm

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.