Compile and install GCC5.3.0 in Linux

Source: Internet
Author: User
Tags gmp

Compile and install GCC5.3.0 in Linux

System Environment: Amazon Linux AMI 2015.09.2 (HVM) --- Fedora 23 Server

1. Download The gcc-5.3.0installation package and put gcc-5.3.0.tar.gz in the/opt directory for decompression:

# Sudo su

# Mkdir/opt/& cd/opt/

# Wget http://ftp.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz

# Tar-zxf gcc-5.3.0.tar.gz

2. Create the installation directory:

# Mkdir/usr/local/The gcc-5.3.0/

# Cd/usr/local/gcc-5.3.0/

3. Configure the installation file:

#/Opt/gcc-5.3.0/configure-prefix =/usr/local/gcc-5.3.0

If the following error occurs during execution:

-----------------------------------------------------------------------

Configure: error: in '/usr/local/gcc-5.3.0 ':
Configure: error: no acceptable C compiler found in $ PATH

See 'config. log' for more details.

-----------------------------------------------------------------------

The C compiler is not found in $ PATH.
If the system has a gcc compiler, set the environment variable.
For example:
Export PATH = $ PATH:/usr/local/bin

If not, install the rpm package of lower gcc versions first.

Installation sequence: cpp-kernel ---> headers ---> glibc ---> devel ---> libgomp ---> gcc

Repeat Step 3 and an error occurs:

Bytes -------------------------------------------------------------------------------------------------
Configure: error: Building GCC requires GMP 4.2 +, MPFR 2.3.1 + and MCM 0.8.0 +.
Try the -- with-gmp, -- with-mpfr and/or -- with-mpc options to specify
Their locations.
Bytes -------------------------------------------------------------------------------------------------

Error Description: To install gcc, you need to install the GMP, MPFR, and MPC libraries. You can download the corresponding compressed packages from ftp://gcc.gnu.org/pub/gcc/infrastructure. Since MPFR depends on GMP, while nmms depends on GMP and MPFR, it is necessary to install GMP first, followed by MPFR, and finally the nmms.

①. Install gmp4.3.2

# Tar jxvf gmp-4.3.2.tar.bz2

# Mkdir/usr/local/gmp-4.3.2

# Cd/usr/local/gmp-4.3.2

#/Opt/gmp-4.3.2/configure-prefix =/usr/local/gmp-4.3.2

# Make

Make install

② Install mpfr2.4.2

# Tar jxvf mpfr-2.4.2.tar.bz2

# Mkdir/usr/local/mpfr-2.4.2

# Cd/usr/local/mpfr-2.4.2

#/Opt/mpfr-2.4.2/configure -- prefix =/usr/local/mpfr-2.4.2 -- with-gmp =/usr/local/gmp-4.3.2
# Make

# Make install

③ Install mpc0.8.1

# Tar-zxf mpc-0.8.1.tar.gz

# Mkdir/usr/local/mpc-0.8.1

# Cd/usr/local/mpc-0.8.1

#/Opt/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

# Make

# Make install

④ Re-install GCC configuration and installation options

# Cd/usr/local/gcc-5.3.0

#/Opt/gcc-5.3.0/configure -- prefix =/usr/local/gcc-5.3.0-enable-threads = posix-disable-checking-disable-multilib-enable-versions ages = 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

4. Compile the Installation File

# Make

Again:

/Usr/local/gcc-5.3.0/./prev-gcc/cc1plus: error while loading shared libraries: libmp C. so.2: cannot open shared object file: No such file or directory
Make [3]: *** [real. o] Error 1
Make [3]: Leaving directory '/usr/local/gcc-5.3.0/gcc'
Make [2]: *** [all-stage3-gcc] Error 2
Make [2]: Leaving directory '/usr/local/gcc-5.3.0'
Make [1]: *** [stage3-bubble] Error 2
Make [1]: Leaving directory '/usr/local/gcc-5.3.0'
Make: *** [all] Error 2
Analysis:/usr/local/gcc-5.3.0/x86_64-unknown-linux-gnu/libgcc/config. log

When an error is found, many errors are found, most of which are not found in the database.

# Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib

# Make

About 30 minutes later ···
Finally, the compilation is successful.

Libtool: link: ranlib. libs/libatomic.
Libtool: link: (cd ". libs" & rm-f "libatomic. la" & ln-s "../libatomic. la" "libatomic. la ")
True DO = all multi-do # make
Make [4]: Leaving directory '/usr/local/gcc-5.3.0/x86_64-unknown-linux-gnu/libatomic'
Make [3]: Leaving directory '/usr/local/gcc-5.3.0/x86_64-unknown-linux-gnu/libatomic'
Make [2]: Leaving directory '/usr/local/gcc-5.3.0/x86_64-unknown-linux-gnu/libatomic'
Make [1]: Leaving directory '/usr/local/gcc-5.3.0'

5. Install gcc:

# Make install

6. Add the new version of gcc to the command search path:

# Ln-s/usr/local/The gcc-5.3.0/bin/gcc
# Ln-s/usr/local/gcc-5.3.0/bin/g ++

7. Add environment variables:

# Vi/etc/bashrc

Add code:

Add the following code:

# Gcc
LD_LIBRARY_PATH =:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.6.1/lib

# Export LD_LIBRARY_PATH

This installation is complete!

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.