编译安装gcc4.9与g++4.9

Published on 2015 - 12 - 29

安装编译器,版本不限

yum install gcc gcc-c++

下载包

wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.gz
tar -zxvf gcc-4.9.3.tar.gz

自动安装依赖包

cd gcc-4.9.3/contrib
./download_prerequisites

编译

./configure --prefix=/usr/local/gcc49 --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j4
make install

替换编译器

cd /usr/local/gcc49/bin
mv /usr/bin/gcc /usr/bin/gcc44
mv /usr/bin/g++ /usr/bin/g++44
ln -s /usr/local/gcc49/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc49/bin/g++ /usr/bin/g++

查看版本

gcc -v
g++ -v