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:
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
As follows:
Wget requests}
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.
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
Installation is complete! Then, 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'
Create a 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