1,从http://ftp.gnu.org/gnu/下载需要的文件
wget -c http://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.bz2
wget -c http://ftp.gnu.org/gnu/mpfr/mpfr-2.4.2.tar.bz2
wget -c http://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz
wget -c http://ftp.gnu.org/gnu/gcc/gcc-3.4.3/gcc-3.4.3.tar.bz2
2,安装顺序:gmp-->mpfr-->mpc-->gcc
(1)安装GMP: tar xjf gmp-4.3.2.tar.bz2 && cd gmp-4.3.2/ ;./configure --prefix=~/gmp/ && make &&make install
(2)安装MPFR:
cd ../ ;tar xjf mpfr-2.4.2.tar.bz2 ;cd mpfr-2.4.2/ ;./configure --prefix=~/mpfr --with-gmp=~/gmp &&make &&make install
(3)安装MPC:
cd ../ ;tar -xzvf mpc-1.0.1.tar.gz ;cd mpc-1.0.1 ;./configure --prefix=~/mpc --with-mpfr=~/mpfr --with-gmp=~/gmp &&make &&make install
(4)export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/share/home/zhanggs/mpc/lib:/share/home/zhanggs/gmp/lib:/share/home/zhanggs/mpfr/lib/
(5)安装GCC:
cd ../ ;tar jxf gcc-3.4.3.tar.bz2 ;cd gcc-3.4.3 ;./configure --prefix=~/gcc --enable-shared --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=~/gmp --with-mpfr=~/mpfr/ --with-mpc=~/mpc/ &&make &&make install
在安装gcc的时候make报错:
__open_missing_mode ();
inlined from ‘collect_execute‘ at ./collect2.c:1535:20:
使用 open 函数的时候,如果在第二个参数中使用了 O_CREAT,就必须添加第三个参数:创建文件时赋予的初始权限。这个取决于 gcc 的版本,有的版本不会报这个错误。
解决方法:
vi ./gcc/collect2.c
把1535行的redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
修改成redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT,0777);
改完之后继续make && make install
(6) 将gcc路径加入~/.bash_profile
vi ~/.bash_profile
PATH=/share/home/zhanggs/gcc/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=/share/home/zhanggs/mpc/lib:/share/home/zhanggs/gmp/lib:/share/home/zhanggs/mpfr/lib:$LD_LIBRARY_PATH
:wq
source ~/.bash_profile
(7)检查是否安装完成
gcc -v
输出:Reading specs from /share/home/zhanggs/gcc/lib/gcc/x86_64-unknown-linux-gnu/3.4.3/specs
Configured with: ./configure --prefix=/share/home/zhanggs/gcc --enable-shared --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/share/home/zhanggs/gmp --with-mpfr=/share/home/zhanggs/mpfr/ --with-mpc=/share/home/zhanggs/mpc/
Thread model: posix
gcc version 3.4.3
参考链接:https://www.cnblogs.com/julie-yang/p/4695845.html
原文地址:https://www.cnblogs.com/wen-yan/p/12545504.html