Install GCC 4.9.2 on Red Hat Enterprise Linux Server 6.5

Source: Internet
Author: User
Tags gmp

Install GCC 4.9.2 on Red Hat Enterprise Linux Server 6.5

Now many programmers are using GCC to better apply GCC. Currently, GCC can be used to compile programs in C/C ++, FORTRAN, JAVA, OBJC, ADA, and other languages. You can select the language to install. This article describes how to install GCC in Linux by taking GCC4.9.2 installation in RedHat Linux as an example (the latest GCC version is not used because it is required during project development.

Before installation, a cc or gcc compiler must be available in the system, or the compiler on the system must be specified using the environment variable CC. If the system does not have a compiler, you cannot install GCC 4.9.2 in the source code form. If this is the case, you can find a GCC software package in binary format such as RPM that suits your system on the Internet for installation and use. This article describes the installation process of the GCC software package provided in the form of source code. The software package itself and its installation process are also applicable to other Linux and Unix systems.

On the System, the original GCC compiler may store command files such as gcc, library files, and header files in different directories of the system. In contrast, we recommend that you install a version of GCC in a separate directory. The advantage of doing so is that you can easily Delete the entire directory without needing it in the future (because GCC does not have the uninstall function ); the disadvantage is that you need to make some settings after installation to make the compiler work normally. This solution is used to install GCC 4.9.2 in this article. After the installation is complete, the GCC compiler of the earlier version can still be used, that is, a system can coexist and use multiple versions of the GCC compiler.

Follow the steps and setup options provided in this article to install a working New version of GCC compiler on the system even if GCC has not been installed before.

1 download

You can find the download resources on the GCC website (http://gcc.gnu.org) or by searching online. The latest GCC version is 4.9.2. Two types of files are available for download: gcc-4.9.2.tar.gzand gcc-4.9.2.tar.bz2. The compression format is different and the content is completely consistent. Download either of them.

RHLinux gcc-4.9.2 installation method is relatively simple, but the installation process in some links need to pay attention to, otherwise, may cause installation failure, or installation error. The installation process is as follows:

First download and decompress the gcc RPM package to the source directory (such as/opt/gcc-4.0.1)

1. decompress the RPM package:

[Root @ bkjia] # tar xjvf gcc-4.0.1.tar.bz2 (decompress and generate the source directory/opt/gcc-4.0.1)

2. Create the installation target directory:

[Root @ linux opt] # mkdir/usr/local/gcc-4.0.1/

3. Go to the installation target directory:

[Root @ linux opt] # cd/usr/local/gcc-4.0.1/(this step is important, you need to execute the configure command in the target directory when configuring the Installation File)

[Root @ linux opt] # pwd

/Usr/local/gcc-4.0.1

4. Configure the installation file:

[Root @ linux gcc-4.0.1] #/opt/gcc-4.0.1/configure -- prefix =/usr/local/gcc-4.0.1/(this step is very important and needs to be under the target directory of the installation, run the configure command in the source directory/opt/gcc-4.0.1/to configure to install gcc to the target directory/usr/local/gcc-4.0.1 /)

Creating cache./config. cache

Checking host system type... i686-pc-linux-gnu

5. Compile the installation file:

[Root @ linux gcc-4.0.1] # pwd

/Usr/local/gcc-4.0.1

[Root @ linux gcc-4.0.1] # make (compile in the target directory)

6. Install gcc:

[Root @ linux gcc-4.0.1] # pwd

/Usr/local/gcc-4.0.1

[Root @ linux gcc-4.0.1] # make install (install in the target directory)

If there are no errors in the steps and commands during the installation process, you will be able to install it successfully.

From svn checkout svn: // gcc.gnu.org/svn/gcc/trunkto get the latest gcccode, computation and compilation of the things about learning c++ 11, the result is the following problem in configure:
Building GCC requires GMP 4.2 +, MPFR 2.3.1 + and MCM 0.8.0 +
1. From http://www.multiprecision.org/index.php? Prog = mpc & page = download the following content: mpc-0.9.tar.gz
2. Renewal
3. http://ftp.gnu.org/gnu/mpfr/download mpfr-3.1.0.tar.xz.
Install GMP first. Decompress the GMP compressed package, get the source code directory gmp-5.0.1. Create a temporary compilation directory under the directory of the same level, named temp here. Then, configure the installation options, go to the temp directory, and enter the following command for Configuration:

../Gmp-5.0.1/configure -- prefix =/usr/local/gmp-5.0.1

Make

Sudo make install

The installation methods of mpfr and nmpc are similar to those of gmp. Note that the dependency options of gmp and mpfr should be added during configuration. The specific configuration commands are as follows:

../Mpfr-3.1.0/configure -- prefix =/usr/local/mpfr-3.1.0 -- with-gmp =/usr/local/gmp-5.0.1

../Mpc-0.9/configure -- prefix =/usr/local/mpc-0.9 -- with-gmp =/usr/local/gmp-5.0.1 -- with-mpfr =/usr/local/mpfr-3.1.0

After these three libraries are installed, you can officially start to install gcc.

Of course, the three libraries that have just been compiled are required during the link.

Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpc-0.9/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.1.0/lib

Then the typical configure, make, and install three steps.

../Trunk/configure -- prefix =/usr/local/gcc-4.7 -- enable-threads = posix -- disable-checking -- disable-multilib -- enable-versions ages = c, c ++
-- With-gmp =/usr/local/gmp-5.0.1 -- with-mpfr =/usr/local/mpfr-3.1.0 -- with-mpc =/usr/local/mpc-0.9

Make

Make check (optional)

Sudo make install

After a long wait:

/Usr/local/gcc-4.7/bin/g + +-v
Use built-in specs.
COLLECT_GCC =/usr/local/gcc-4.7/bin/g ++
COLLECT_LTO_WRAPPER =/usr/local/gcc-4.7/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Goals: x86_64-unknown-linux-gnu
Configuration :.. /trunk/configure -- prefix =/usr/local/gcc-4.7 -- enable-threads = posix -- disable-checking -- disable-multilib -- enable-versions ages = c, c ++ -- with-gmp =/usr/local/gmp-5.0.1 -- with-mpfr =/usr/local/mpfr-3.1.0 -- with-mpc =/usr/local/mpc-0.9
Thread model: posix
Gcc 4.7.0 20120113 (experimental) (GCC)

I started learning C ++ 11.

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

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 Vim + GCC + GDB in Ubuntu

Switch two GCC versions in Ubuntu

CentOS6.5 upgrade to manually install GCC4.8.2

GCC details: click here
GCC: click here

This article permanently updates the link address:

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.