Compile and install GCC 4.9.2 in CentOS 6.5

Source: Internet
Author: User

Compile and install GCC 4.9.2 in CentOS 6.5

Environment: CentOS-6.5, gcc-4.4.7 system must have installed a compiler, because gcc also needs to be compiled, it is recommended to install with root

First, three additional libraries are required for gcc compilation. Download and install them in the following order:

1. gmp Co ftp://ftp.gnu.org/gnu/gmp

2. mpfr ftp://ftp.gnu.org/gnu/mpfr

3. mpc http://www.multiprecision.org/mpc

Preparations:
1. Compile and install gmp
# Tar-zxvf gmp-5.1.3.tar.gz

# Cd gmp-5.1.3

#./Configure

# Make & make install

2. Compile and install mpfr
# Tar-zxvf mpfr-3.1.2.tar.gz

# Cd mpfr-3.1.2

#./Configure

# Make & make install

 

3. Compile and install the mpc
# Tar-zxvf mpc-1.0.tar.gz

# Cd mpc-1.0

#./Configure

# Make & make install

1. First download the source code
Wgethttp: // ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2

2. Extract
Tar-jxvf gcc-4.9.2.tar.bz2

3. Download the dependencies required for compilation.
Cd gcc-4.9.2

./Contrib/download_prerequisites

Cd ..

4. Create a compilation output directory
Mkdir gcc-build-4.9.2

5. Go to the directory and run the following command to generate the makefile file.
Cd gcc-build-4.9.2

../Gcc-4.9.2/configure -- enable-checking = release -- enable-packages ages = c, c ++ -- disable-multilib

Gcc compilation parameters:

-- Enable-languages ages // specifies the language files that gcc can compile. Each language is separated by commas (,), such as c, c ++, and java.

-- Disable-multilib // by default, gcc can compile the code into a 64-bit program on a 32-bit system, or compile the code into a 32-bit program on a 64-bit system, if this compilation option is added, the gcc cross-compilation function is disabled.

6. Execute the following command to compile
Make-j4 // The Machine is dual-core, so j4 can speed up compilation.

Have a coffee and chat, and then compile it.

 

The following problems occurred during this period:

 

Error 1:

Configure: error: C ++ compiler missing orinoperational

Make [2]: \ *** [configure-stage1-libcpp] Error 1

Make [2]: Leaving directory '/home/liukk/gcc-4.8.1'

Make [1]: \ *** [stage1-bubble] Error 2

Make [1]: Leaving directory '/home/liukk/gcc-4.8.1'

Make: \ *** [all] Error 2

Solution:

Install the following content:

Yum install gcc-c ++

Linux GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit edition as an example)

Install and use Vim + GCC + GDB in Ubuntu

Switch two GCC versions in Ubuntu

CentOS6.5 upgrade to manually install GCC4.8.2

GCC details: click here

This article permanently updates the link address:

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.