1. 程式人生 > >centos 6.4編譯gcc升級過程

centos 6.4編譯gcc升級過程

0.安裝需要的庫

sudo yum -y install glibc-devel.i686 glibc-devel

1.下載gcc

wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.4/gcc-4.6.4.tar.bz2

tar -jxvf gcc-4.6.4.tar.bz2

2.下載依賴庫

cd gcc-4.6.4 
檢視檔案./contrib/download_prerequisites,下載依賴庫,預設下載太慢,可以用迅雷

 ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2

ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2

ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz

解壓

tar xjf gmp-4.3.2.tar.bz2
tar xjf mpfr-2.4.2.tar.bz2
tar xzf mpc-0.8.1.tar.gz

移動

mv ./gmp-4.3.2 ./gcc-4.6.4/gmp
mv ./mpfr-2.4.2 ./gcc-4.6.4/mpfr
mv ./mpc-0.8.1 ./gcc-4.6.4/mpc

3.編譯

cd gcc-4.6.4

mkdir gcc-build-4.6.4
cd gcc-build-4.6.4
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

make -j4

4.安裝,預設安裝到/usr/local/bin
sudo make install

檢視版本 gcc -v,一般就是新版本了

5.配置

vim /etc/profile

新增

export PATH=/usr/local/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH

ok!

5.3.0 編譯彙總

sudo yum -y install glibc-devel.i686 glibc-devel


tar xjf gcc-5.3.0.tar.bz2
tar xvf gmp-6.1.0.tar
tar xjf mpfr-3.1.4.tar.bz2
tar xzf mpc-1.0.3.tar.gz


mv ./gmp-6.1.0 ./gcc-5.3.0/gmp
mv ./mpfr-3.1.4 ./gcc-5.3.0/mpfr
mv ./mpc-1.0.3 ./gcc-5.3.0/mpc


cd gcc-5.3.0
mkdir gcc-build-5.3.0
cd gcc-build-5.3.0
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib --prefix=/usr/local/gcc-5.3.0
make -j4
sudo make install