Source Code Compilation Installation gcc-5.3.0

Source: Internet
Author: User
Tags gmp

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

1. Download the gcc-5.3.0 installation package and put the gcc-5.3.0.tar.gz into the/opt directory to extract:

#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/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 when executing:

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

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

See ' Config.log ' for more details.

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

Note that C's compiler was not found in $path.
If the system has a GCC compiler, set the environment variable
Like what:
Export path= $PATH:/usr/local/bin

If not found then install the GCC low version RPM package first

Installation order: Cpp-kernel--->headers--->glibc--->headers--->glibc--->devel--->libgomp--->gcc

Repeat step 3, and there are related errors:

-------------------------------------------------------------------------------------------------
Configure:error:Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the--WITH-GMP,--WITH-MPFR and/or--WITH-MPC options to specify
their locations.
-------------------------------------------------------------------------------------------------

Error description: To install GCC requires GMP, MPFR, MPC these three libraries, you can download the corresponding compression package from ftp://gcc.gnu.org/pub/gcc/infrastructure/. Because MPFR relies on GMP, and MPC relies on GMP and MPFR, so we should install GMP first, next MPFR, the last is MPC.

①. Installing 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

② installation 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

③ installation 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

④ Installing the GCC configuration installation option again

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

4. compiling the installation files

#make

Error again:

/usr/local/gcc-5.3.0/./prev-gcc/cc1plus:error while loading shared Libraries:libmpc.so.2:cannot open Shared object fil E: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

Finding the next error will find many errors, most of which are not found in the library.

#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

After about a min ...
Finally the compilation succeeded.

Libtool:link:ranlib. libs/libatomic.a
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. Perform the installation of GCC:

#make Install

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

#ln-S/USR/LOCAL/GCC-5.3.0/BIN/GCC gcc
#ln-S/usr/local/gcc-5.3.0/bin/g++ 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

The installation is complete!

Source Code Compilation Installation gcc-5.3.0

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.