Install the latest gcc4.2.2 in Linux

Source: Internet
Author: User
Tags systemtap gfortran
Install the latest gcc4.2.2-Linux general technology-Linux programming and kernel information under Linux. For more information, see below. Very simple. First of all, the latest package GCC 4.2.bz2 is usually available everywhere. The download speed in linux is very full, more than 20 k, which is disgusting. I like the download speed of thunder, download in windows, about 42 M, download speed 2 to 4 M, return to linux, mount, ntfs format me, not to mention it, say install!

Go to the mounted directory, cp GCC4.2.bz2/azuo first,

Cd/azuo,

Tar-xvf GCC 4.2.bz2,

Get gcc-4.2,

Cd gcc-4.2, creating a folder under the/usr directory is now the directory to store the new gcc,

Mkdir/usr/gcc4

./Configure? Prefix =/usr/gcc4

Press enter and there will be configuration information, as long as no error is reported,

Make, this process has been a long time, because I have not set some specific options, so almost all components need to be compiled once, my computer cpu: AMD 3200 + X2, GB memory, it takes about one and a half hours.

By this time, nothing has been found in/usr/gcc4, and the compilation process occurs in the source folder. Let's take another action, all the things to be used will be configured under the target folder,

Make install;

This process is not short. Just wait.

After everything is done, you can use the latest gcc. You can see that gcc, g ++, and other things in/usr/gcc4/bin are available, write two programs:

Aa. c:

1 # include

2

3 int main (void ){

4 printf ("ad ");

5 return 1;

6}

Gcc-o aa. c

Run./aa

The above is c, and the following is c ++:

A. cpp:

1 # include

2 using namespace std;

3 int main (void ){

4 cout <"OK! "<Endl;

5 return 1;

6}

G ++-o a. cpp

Run it./

If everything is okay, you can replace the original gcc tool with the latest one.

Let's take a look at the original gcc version, so we can uninstall it:

[Root @ BTazuo bin] # rpm-qa gcc

Gcc-4.1.2-27.fc7

[Root @ BTazuo bin] # rpm-e gcc-4.1.2-27.fc7

Error: Failed dependencies:

Gcc is needed by (installed) systemtap-0.5.13-1.fc7.i386

Gcc = 4.1.2-27. fc7 is needed by (installed) gcc-c ++-4.1.2-27. fc7.i386

Gcc = 4.1.2-27. fc7 is needed by (installed) gcc-gfortran-4.1.2-27. fc7. i386

[Root @ BTazuo bin] # rpm-e gcc-c ++-4.1.2-27. fc7.i386

[Root @ BTazuo bin] # rpm-e gcc-gfortran-4.1.2-27.fc7.i386

[Root @ BTazuo bin] # rpm-e gcc-4.1.2-27.fc7

Error: Failed dependencies:

Gcc is needed by (installed) systemtap-0.5.13-1.fc7.i386

[Root @ BTazuo bin] # g ++

Bash: g ++: command not found

Uninstalled successfully

[Root @ BTazuo bin] # gcc

Gcc: no input file.

[Root @ BTazuo bin] # rpm-e systemtap-0.5.13-1.fc7.i386

[Root @ BTazuo bin] # gcc

Gcc: no input file

[Root @ BTazuo bin] # rpm-e gcc-4.1.2-27.fc7

[Root @ BTazuo bin] # gcc

Bash:/usr/lib/ccache/gcc: the file or directory does not exist.

The last unmount is successful!

At this time, please note that my gcc is under/usr/bin and under/usr/lib/ccache, create a link for both of the following:

[Root @ BTazuo bin] # ln-s/usr/gcc4/bin/g ++

[Root @ BTazuo bin] # g ++

G ++: no input file

It can be seen that g ++ has been installed and can be used.

Then gcc:

[Root @ BTazuo bin] # ln-s/usr/gcc4/bin/gcc

[Root @ BTazuo bin] # gcc

Bash:/usr/lib/ccache/gcc: the file or directory does not exist.

[Root @ BTazuo bin] #./gcc

Gcc: no input file

You can also create a gcc link for another directory:

[Root @ BTazuo lib] # ln-s/usr/gcc4/bin/gcc/usr/lib/ccache/gcc

[Root @ BTazuo lib] # gcc

Gcc: no input file

So far, both gcc and g ++ have been established and can be used. Finally, the original package and decompression files can be deleted to save hard disk space!
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.