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.t
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:
To download the following package: gcc-4.6.1.tar.bz2 gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.bz2: wget Done} wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2 can be!
2. unzip and install the tool in the following sequence: GMP, MPFR, MPC, and GCC.
Install GMP: tar jxf gmp-4.3.2.tar.bz2 & cd gmp-4.3.2/;./configure? Prefix =/usr/local/gmp/& make install
Install MPFR:
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:
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:
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:
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.
Make & make install is complete! Then you can make a link to use GCC mkdir-p/data/backup/'date + % Y % m % d' mv/usr/bin/{gcc, g ++}/data/backup/'date + % Y % m % d' new soft link: ln-s/usr/local/gcc/bin/gcc/usr/bin/gcc 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:
#!/bin/sh ##auto make install gcc ##2012-07-03 tar jxf gmp-4.3.2.tar.bz2 &&cd gmp-4.3.2/ ;./configure ?prefix=/usr/local/gmp/ &&make &&make install sleep 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 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 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/ if [ $? -eq 0 ];then echo “This gcc configure is success” else echo “This gcc configure is failed” fi export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/ make && make install [ $? -eq 0 ]&&echo This is make install success