linux编译安装gcc5.3.0
作者:互联网
1、下载GCC5.3.0安装包
#su #cd /opt #wget http://ftp.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
2、解压
#tar -zxf gcc-5.3.0.tar.gz
3、创建安装目录
#mkdir /usr/local/gcc-5.3.0/ #cd /usr/local/gcc-5.3.0/
4、配置安装
#/opt/gcc-5.3.0/configure -prefix=/usr/local/gcc-5.3.0
如果出现如下错误:
说明缺少依赖库GMP、MPFR、MPC,可以从ftp://gcc.gnu.org/pub/gcc/infrastructure/下载,按下面顺序安装。
⑴ 安装GMP4.3.2
#cd /opt #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2 #tar jxvf gmp-4.3.2.tar.bz2 #mkdir /usr/local/gmp-4.3.2 #cd /usr/local/gmp-4.3.2 #/opt/gmp-4.3.2/configure -prefix=/usr/local/gmp-4.3.2 #make #make install
⑵ 安装MPFR2.4.2
#cd /opt #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2 #tar jxvf mpfr-2.4.2.tar.bz2 #mkdir /usr/local/mpfr-2.4.2 #cd /usr/local/mpfr-2.4.2 #/opt/mpfr-2.4.2/configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2 #make #make install
⑶ 安装MPC0.8.1
#cd /opt #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz #tar -zxf mpc-0.8.1.tar.gz #mkdir /usr/local/mpc-0.8.1 #cd /usr/local/mpc-0.8.1 #/opt/mpc-0.8.1/configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 #make #make install
5、再次配置GCC安装配置选项
#cd /usr/local/gcc-5.3.0 #/opt/gcc-5.3.0/configure --prefix=/usr/local/gcc-5.3.0 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
6、编译
#make
大约半小时编译完成......
7、安装
#make install
8、软链接
#ln -s /usr/local/gcc-5.3.0/bin/gcc gcc #ln -s /usr/local/gcc-5.3.0/bin/g++ g++
9、添加环境变量
# vim /etc/bashrc
添加如下代码:
#gcc LD_LIBRARY_PATH=:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-5.3.0/lib:/usr/local/gcc-5.3.0/lib64 #export LD_LIBRARY_PATH
安装完毕!
标签:gcc,5.3,tar,编译,gcc5.3,usr,linux,gmp,local 来源: https://blog.csdn.net/baidu_33008169/article/details/122116348