The latest version gcc5.3 installation detailed

Source: Internet
Author: User
Tags bz2 gmp

1. Download gcc-5.3 installation package
GCC versions browse Address: http://ftp.gnu.org/gnu/gcc/
gcc-5.3 Browse Address: http://ftp.gnu.org/gnu/gcc/gcc-5.3/
gcc-5.3 Download Address: http://ftp.gnu.org/gnu/gcc/gcc-5.3/gcc-5.3.tar.bz2
2. put the gcc-5.3.tar.bz2 into the/opt folder to extract
[Root@rekfan.com ~]# cd/opt
[root@rekfan.comopt]# tar xjvf gcc-5.3.tar.bz2
3. Create installation directory
[root@rekfan.comopt]# mkdir/usr/local/gcc-5.3/
4. Enter the installation directory
[root@rekfan.comopt]# cd/usr/local/gcc-5.3/
5. Configure installation files
[root@rekfan.comgcc-5.3]#/opt/gcc-5.3/configure--prefix=/usr/local/gcc-5.3
(Execute the Configure command in the source directory/opt/gcc-5.3/, configure to install GCC under the target directory/usr/local/gcc-5.3/, where the –prefix option represents where to install the library, I am installed in/usr/local/ gcc-5.3 directory, this option is used for subsequent installations.

If you perform this step, you receive the following error:
----------------------------------------------------------------------------------
[Root@rekfan.com gcc-5.3]#/opt/gcc-5.3/configure--prefix=/usr/local/gcc-5.3/
Checking build system Type ... I686-pc-linux-gnu
Checking host system Type ... I686-pc-linux-gnu
Checking target system Type ... I686-pc-linux-gnu
Checking for a bsd-compatible install .../usr/bin/install-c
Checking whether LN works ... yes
Checking whether Ln-s works ... yes
Checking for a sed this does not truncate output .../bin/sed
Checking for gawk ... gawk
Checking for gcc ... no
Checking for cc ... no
Checking for cl.exe ... no
configure:error:in '/usr/local/gcc-5.3 ':
Configure:error:no acceptable C compiler found in $PATH

"Config.log ' for more details."
----------------------------------------------------------------------------------
The above error indicates that the C 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, install GCC's low version RPM package first
Insert a Linux software disk (usually in the first or second), mount the disc, and install it in the following order:

[Root@rekfan.com opt]# rpm-ivhcpp-4.1.2-48.el5.i386.rpm
[Root@rekfan.com opt]# rpm-ivhkernel-headers-2.6.18-194.el5.i386.rpm
[Root@rekfan.com opt]# rpm-ivhglibc-headers-2.5-49.i386.rpm
[Root@rekfan.com opt]# rpm-ivhglibc-devel-2.5-49.i386.rpm
[Root@rekfan.com opt]# rpm-ivhlibgomp-4.4.0-6.el5.i386.rpm
[Root@rekfan.com opt]# rpm-ivhgcc-4.1.2-48.el5.i386.rpm

Repeat step 5 for a new error, and here is a partial error code. If there are no errors, skip directly to step 7!
----------------------------------------------------------------------------------
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 the GMP, MPFR, MPC 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. The three libraries I use are gmp4.3.2,mpfr2.4.2 and mpc0.8.1, all placed under the/opt folder.
①. Install gmp4.3.2
[Root@rekfan.com opt]# tar jxvf gmp-4.3.2.tar.bz2
[Root@rekfan.com opt]# mkdir/usr/local/gmp-4.3.2
[Root@rekfan.com opt]# cd/usr/local/gmp-4.3.2
[Root@rekfan.com gmp-4.3.2]#/opt/gmp-4.3.2/configure--prefix=/usr/local/gmp-4.3.2
[Root@rekfan.com gmp-4.3.2]# make (compiled)
[Root@rekfan.com gmp-4.3.2]# make install (perform installation)
② installation mpfr2.4.2
[Root@rekfan.com opt]# tar jxvf mpfr2.4.2.tar.bz2
[Root@rekfan.com opt]# mkdir/usr/local/mpfr-2.4.2
[Root@rekfan.com opt]# cd/usr/local/mpfr-2.4.2
[Root@rekfan.com 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
(Note that the dependency options are added when configuring)
[Root@rekfan.com mpfr-2.4.2]# make
[Root@rekfan.com mpfr-2.4.2]# make install
③ installation mpc0.8.1
[Root@rekfan.com opt]# tar jxvf gmpc0.8.1.tar.bz2
[Root@rekfan.com opt]# mkdir/usr/local/mpc-0.8.1
[Root@rekfan.com opt]# cd/usr/local/mpc-0.8.1
[Root@rekfan.com 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
[Root@rekfan.com mpc-0.8.1]# make
[Root@rekfan.com mpc-0.8.1]# make install
④ Install GCC again configure installation options
[Root@rekfan.com mpc-0.8.1]# cd/usr/local/gcc-5.3
[Root@rekfan.com gcc-5.3]#/opt/gcc-5.3/configure--prefix=/usr/local/gcc-5.3-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

6. Compiling installation files
[root@rekfan.comgcc-5.3]# Make
It takes about 1 hours, a cup of coffee, and slowly wait.
One hours later ...
The second error occurred:

Open/usr/local/gcc-5.3/i686-pc-linux-gnu/libgcc/config.log
Ctrl+f Lookup error found the following errors
/----------------------------------------------------------------------------------
/usr/local/gcc-5.3/./gcc/cc1:error while loading shared libraries:libmpc.so.2:cannot open shared object File:no such fi Le or directory
configure:3058: $? = 1
----------------------------------------------------------------------------------/
Found the solution on the Internet, you need to add environment variable Ld_library_path to indicate the location of the previous three libraries, type the following command:
[root@rekfan.comgcc-5.3]# exportld_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
Perform the steps again 6→
About three hours later ...
Finally compiled successfully, the effect of the map into the following:

7. Perform installation gcc
[root@rekfan.comgcc-5.3]# make install
[root@rekfan.com gcc-5.3]# 
If this is not an accident, the installation should be successful now, but it is still not possible to use the new version of GCC because the new version of GCC has not been added to the command search path.
8. To establish a soft link
[root@rekfan.com/]# sudoln-s/usr/local/gcc-5.3/bin/gcc gcc461
[ root@rekfan.com/]# sudo ln-s/usr/local/gcc-5.3/bin/g++ g++461
9. add environment variable  
Open the BASHRC file under the/etc directory to add the following code:
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-5.3/lib Exportld_library_path

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.