CentOS 6.3 Compile and install gcc clear and easy tutorials (most Linux versions available)

Source: Internet
Author: User

As we all know: CentOS Although easy to use, but its own Yum source is very small also lag, installation tools often need their own download source code compiled. (Looks like Redhat and Fedora Source El version of the same RPM can also be used, but did not try)

Other tools to slow down a little bit, the most unacceptable is that its GCC version is so lagging behind, up to now (2012-12-21) The latest version of the CentOS is 6.3, the official source of the latest GCC version is 4.4.6. Now the latest stable version of GCC is 4.7.2, and the development version is up to 4.8.

Friends of C + + know that this version of the upgrade time is precisely the various compilers want to c++11 standard fast approaching time, but also more and more people to use the c++11 characteristics of the period, so upgrade a more functional gcc is not.

Well, the importance of the discussion, the following start to talk about business.

Related reading:

VMware Virtual Machine installation CentOS 6.3 See http://www.linuxidc.com/Linux/2012-12/76583.htm

The environment of the landlord is CentOS version 6.3, using the default GCC 4.4.6, compile and install GCC 4.7.2.

On the Internet to upgrade the compilation of GCC tutorials a lot of steps are very cumbersome, painful process I do not say, I only say a little, in fact, things can be very simple.

The first is dependent on the library, the official document said the need for GMP, MPC, MPFR, and provide a download address, many tutorials have said their own compile installation, and the process of some of the problems, in fact, there is no need to be so troublesome. Don't we ever think of GCC as a multi-year and mature project, does it not provide some automated solutions?

Step 1:

Yum Install glibc-static libstdc++-static-y

Install C and C + + static libraries (it is said that if the system is missing LIBC.A and libstdc++.a compile error, but I do not have so much leisure to try, the practice of friends can reply, share the experience, so that everyone long insight)

Step 2:

Download decompression gcc, my gcc directory is gcc-4.7.2.

Step 3:

Enter the GCC directory and execute:

./contrib/download_prerequisites

This magical script file will help us download, configure, and install the three dependent libraries. Can save us a lot of time and energy.

Step 4:

Do you think that these three libraries are automatically downloaded, automatic make install is OK? Wrong.

A lot of people are making all sorts of weird mistakes when compiling gcc, and that's not a good step.

They are not yet in the search path of the. So file, you need to add in, and finally remember to make sure to perform a ldconfig.

The general practice is:

1, find out which directory your shared library files are install to (updatedb+locate command).

2, if your library is not placed directly under/lib or/usr/lib, you need to modify the/etc/ld.so.conf file and add the path to your shared library

3, if you add a shared library path in 2, remember to perform a ldconfig, update the response cache file so the system can find your shared library.

How to take part in my last blog "Linux Shared library path configuration" http://blog.csdn.net/yanxiangtianji/article/details/8316562

Step 5:

Create a temporary directory that is used to store a large number of temporary files at compile time, which is required in the documentation requirements.

I built a directory called build under gcc-4.7.2 and entered it.

mkdir Build

CD Build

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.