CentOSGCC upgrade tutorial

Source: Internet
Author: User
Recently due to reasons of demand, need to upgrade the current gcc-4.4.4 to gcc-4.6.1, considering there are multiple reasons, made a script automatic installation combined with batch tool distribution. I. installation environment version: centos6.0X64 original GCC version: gcc-4.4.4 new GCC version: gcc-4.6.1 II, formal installation 1, download the installation of source code: the following need to download the following package: gcc-4.6.1.tar.bz2gmp-4.3.2.tar.bz2mpc-0.8.1.tar.g

Recently due to reasons of demand, need to upgrade the current gcc-4.4.4 to gcc-4.6.1, considering there are multiple reasons, made a script automatic installation combined with batch tool distribution.

I. installation environment
System version: centos6.0X64
GCC version: gcc-4.4.4
New GCC: gcc-4.6.1

II. formal installation
1. download and install the source code:

 
 
  1. The following package needs to be downloaded: gcc-4.6.1.tar.bz2 gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.bz2

  2. As follows:

  3. Wget requests}

  4. Wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2!

2. unzip and install the tool in the following sequence: GMP, MPFR, MPC, and GCC.

 
 
  1. Install GMP: tar jxf gmp-4.3.2.tar.bz2 & cd gmp-4.3.2/;./configure? Prefix =/usr/local/gmp/& make install

Install MPFR:

 
 
  1. cd ../ ;tar jxf mpfr-2.4.2.tar.bz2 ;cd mpfr-2.4.2/ ;./configure ?prefix=/usr/local/mpfr ?with-gmp=/usr/local/gmp &&make &&make install

Install the MPC:

 
 
  1. cd ../ ;tar xzf mpc-0.8.1.tar.gz ;cd mpc-0.8.1 ;./configure ?prefix=/usr/local/mpc ?with-mpfr=/usr/local/mpfr ?with-gmp=/usr/local/gmp &&make &&make install

Install GCC:

 
 
  1. cd ../ ;tar jxf gcc-4.6.1.tar.bz2 ;cd gcc-4.6.1 ;./configure ?prefix=/usr/local/gcc ?enable-threads=posix ?disable-checking ?disable-multilib ?enable-languages=c,c++ ?with-gmp=/usr/local/gmp ?with-mpfr=/usr/local/mpfr/ ?with-mpc=/usr/local/mpc/ &&make &&make install

Run the following command:

 
 
  1. export  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/

// This step is critical. if you do not set the variable, an error is returned.

 
 
  1. Make & make install

  2. Installation is complete! Then, make a link to use GCC.

  3. Mkdir-p/data/backup/'date + % Y % m % d'

  4. Mv/usr/bin/{gcc, g ++}/data/backup/'date + % Y % m % d'

  5. Create a soft link:

  6. Ln-s/usr/local/gcc/bin/gcc/usr/bin/gcc

  7. Ln-s/usr/local/gcc/bin/g ++/usr/bin/g ++

III. test GCC
Directly enter gcc-v to view the gcc version 4.6.1 and related compilation parameters! Attach a simple installation script:

 
 
  1. #!/bin/sh  

  2. ##auto make install gcc  

  3. ##2012-07-03  

  4. tar jxf gmp-4.3.2.tar.bz2 &&cd gmp-4.3.2/ ;./configure ?prefix=/usr/local/gmp/ &&make &&make install    

  5. sleep 1    

  6. cd ../ ;tar jxf mpfr-2.4.2.tar.bz2 ;cd mpfr-2.4.2/ ;./configure ?prefix=/usr/local/mpfr ?with-gmp=/usr/local/gmp &&make &&make install    

  7. cd ../ ;tar xzf mpc-0.8.1.tar.gz ;cd mpc-0.8.1 ;./configure ?prefix=/usr/local/mpc ?with-mpfr=/usr/local/mpfr ?with-gmp=/usr/local/gmp &&make &&make install    

  8. cd ../ ;tar jxf gcc-4.6.1.tar.bz2 ;cd gcc-4.6.1 ;./configure ?prefix=/usr/local/gcc ?enable-threads=posix ?disable-checking ?disable-multilib ?enable-languages=c,c++ ?with-gmp=/usr/local/gmp ?with-mpfr=/usr/local/mpfr/ ?with-mpc=/usr/local/mpc/    

  9. if

  10. [ $? -eq 0 ];then    

  11. echo “This gcc configure is success”    

  12. else

  13. echo “This gcc configure is failed”    

  14. fi    

  15. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/    

  16. make && make install    

  17. [ $? -eq 0 ]&&echo This is make install success


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.