CentOS Compiler installs GCC 4.9.2 success

Source: Internet
Author: User
Tags gmp posix

Compiling and installing GCC on Linux is an annoyance, and for someone like me who is accustomed to using a binary installer on Windows, self-compiled installation of GCC is a considerable challenge, and today directly challenges the latest version of GCC, which is 4.9.2 version, before doing a lot of data, The system used for this installation is CentOS6.4, and the self-brought GCC is 4.4.7 version, the specific toss over into the following:

Preparatory work,

To GNU official FTP download GCC source package gcc-4.9.2.tar.gz.

Download the following three dependent installation packages, the versions of these three packages are indicated in the gcc-4.9.2/contrib/download_prerequisites script file and can be downloaded as specified in this version:

ftp://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.bz2

http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2

Http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz

Compile:

First, compile and install the three dependent libraries, and follow the steps to compile the installation:

One: Unzip the gmp-4.3.2.tar.bz2 to a directory of your own, such as/home/[your user name]/gmp-4.3.2, in addition to build a/home/[your user name]/gmp-build directory, and enter this directory, in the terminal to execute. /gmp-4.3.2/configure--prefix=/usr/local/gmp-4.3.2,--prefix indicates the target location to be installed later, and this path is used when compiling gcc. After execution, the makefile file is generated in the current directory, you can do make (start compiling), then perform the Do Test (pre-compilation test, in order to save time, I generally do not perform this step), and finally execute the Do install ( Formally began to install the compiled files to--prefix specified location).

Second: Install MPFR-2.4.2.TAR.BZ2, the same method as above, but the specific parameters of the implementation of configure are as follows. /mpfr-2.4.2/configure--prefix=/usr/local/mpfr-2.4.2--with-gmp=/usr/local/gmp-4.3.2, it is to rely on the previous GMP.

Three: Install the Mpc-0.8.1.tar.gz method as above, but the specific parameters of the execution configure are as follows. /mpc-0.8.1/configure--prefix=/usr/local/mpc-0.8.1--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/ mpfr-2.4.2

Once the above three dependent libraries are installed, you can begin compiling and installing gcc-4.9.2.tar.gz:

Four: In fact, the steps are the same as installing the above three dependent libraries, or the parameters of the execution configure are different. /gcc-4.9.2/configure--prefix=/usr/local/gcc-4.9.2--enable-threads=posix--disable-checking--disable-multilib-- enable-languages=c,c++--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2--with-mpc=/usr/local/ mpc-0.8.1, the parameter here is to add the above three dependent libraries, after the completion of the same is generated makefile file.

Five: Execute make-j4 (-j4 is to start four threads, can fully play the performance of the quad-core CPU, online someone with four-core CPU to open 4 thread compilation took only half an hour, but my Computer configuration is poor, only performed make spent three hours, hehe).

VI: Maketest (I basically omitted this step in order to save time)

Seven: make install (start installation)

At this point, even the compilation installation is complete.

In fact, in the above implementation of the fifth step, you will encounter such an error: "Configure:error:cannot compute suffix of object files:cannot compile", The reason for the online survey is that the above three dependent LIB locations could not be found, so a command should be executed before fifth step export ld_library_path= $LD _library_path:/usr/local/gmp-4.3.2/lib :/usr/local/mpc-0.8.1/lib:/usr/local/mpfr-2.4.2/lib, so that three dependent libraries are added to the environment variables, and then compile the time will not be error.

When you're done, check the version

[[email protected] Desktop]$ g++49-v
uses built-in specs.
collect_gcc=g++49
Collect_lto_wrapper=/usr/local/gcc-4.9.2/libexec/gcc/i686-pc-linux-gnu/4.9.2/ Lto-wrapper
Target: I686-pc-linux-gnu
is configured to:.. /gcc-4.9.2/configure--prefix=/usr/local/gcc-4.9.2--enable-threads=posix--disable-checking--disable-multilib-- enable-languages=c,c++--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2--with-mpc=/usr/local/ mpc-0.8.1
Threading Model: POSIX
gcc version 4.9.2 (gcc)
[[email protected] Desktop]$ gcc49-v
Use built-in specs.
Collect_gcc=gcc49
Collect_lto_wrapper=/usr/local/gcc-4.9.2/libexec/gcc/i686-pc-linux-gnu/4.9.2/ Lto-wrapper
Target: I686-pc-linux-gnu
is configured to:.. /gcc-4.9.2/configure--prefix=/usr/local/gcc-4.9.2--enable-threads=posix--disable-checking--disable-multilib-- enable-languages=c,c++--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2--with-mpc=/usr/local/ mpc-0.8.1
Threading Model: POSIX
gcc version 4.9.2 (gcc)
[[email protected] Desktop]$

CentOS Compilation installs GCC 4.9.2 success

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.