Original URL:
Http://www.cnblogs.com/clark168/p/5339361.html
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 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 installation directory:
#mkdir/usr/local/gcc-5.3.0/
#cd/usr/local/gcc-5.3.0/
3. Configure installation files:
#/opt/gcc-5.3.0/configure–prefix=/usr/local/gcc-5.3.0
If executed, the following error occurs:
-----------------------------------------------------------------------
Configure:error:in '/usr/local/gcc-5.3.0 ':
Configure:error:no acceptable C compiler found in $PATH
"Config.log ' for more details."
-----------------------------------------------------------------------
That means the compiler for C 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, install GCC's low version RPM package first
Installation order: Cpp-kernel--->headers--->glibc--->headers--->glibc--->devel--->libgomp--->gcc
Repeat step 3, and the related error occurs:
-------------------------------------------------------------------------------------------------
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, can download the corresponding compression package from the ftp://gcc.gnu.org/pub/gcc/infrastructure/. Because MPFR rely on GMP, and the MPC relies on GMP and MPFR, so first install GMP, followed by MPFR, the final is the MPC.
①. 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
② 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
④ Install GCC again configure 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-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, compile the installation file
#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
Look up the error will find a lot of 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 installation 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
This installation is complete.