- 前言
安装ubuntu 14.04后,默认gcc为4.8.4,现在需要安装gcc-5.3.0,安装前需要先安装依赖库GMP4.3.2,MPFR2.4.2,MPC0.8.1
1.安装m4
sudo apt-get install m4
2.安装GMP4.3.2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar -jxvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure
make -j4
make install
3.安装MPFR2.4.2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar -jxvf gmpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure
make -j4
make install
4.安装MPC0.8.1
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar -zxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure
make -j4
make install
5.安装autoconf-2.69.tar.gz
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar -zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make -j4
make install
6.安装isl-0.12.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
tar -jxvf isl-0.12.2.tar.bz2
cd isl-0.12.2
./configure
make -j4
make install
7.配置共享库路径
LD_LIBRARY_PATH="/usr/local/lib"
8.安装gcc 5.3.0
wget ftp.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
tar -zxvf gcc-5.3.0.tar.gz
cd /usr/local/
mkdir gcc-5.3.0
cd gcc-5.3.0
/mnt/hgfs/projects/gcc-5.3.0/configure -prefix=/usr/local/gcc-5.3.0/ --enable-threads=posix --disable-checking --enable-languages=c,c++ --disable-multilib --disable-nls --program-suffix=5.3.0
make
make install
9.建立软链接
rm /usr/bin/gcc
ln -sv /usr/local/gcc-5.3.0/bin/gcc5.3.0 /usr/bin/gcc
rm /usr/bin/g++
ln -sv /usr/local/gcc-5.3.0/bin/g++5.3.0 /usr/bin/g++
10.验证
gcc -v