大家好,又见面了,我是你们的朋友全栈君。
- 下载 gcc-7.3.0.tar.gz from
https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz.
有一些依赖提前安装:
代码语言:javascript复制sudo apt install libgmp-dev
sudo apt install libmpfr-dev
sudo apt install libmpc-dev
sudo apt install libisl-dev
sudo apt install zlib1g-dev
sudo apt-get install texinfo
(建议重启) 主要依赖库包如下(仅限于gcc-7.3.0版本):
代码语言:javascript复制wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
把下载好的文件放到gcc文件夹下~ 然后运行:
代码语言:javascript复制./contrib/download_prerequisites
- 解压编译依赖 2.1 解压编译依赖gmp-6.1.0.tar.bz2
tar jxvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
./configure --prefix=/usr/local/gmp
make && make install
2.2 解压编译依赖mpfr-3.1.4.tar.bz2
代码语言:javascript复制tar jxvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make && make install
2.3 解压编译依赖mpc-1.0.3.tar.gz
代码语言:javascript复制tar zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr
make && make install
2.4 解压编译依赖isl-0.16.1.tar.bz2
代码语言:javascript复制tar jxvf isl-0.16.1.tar.bz2
cd isl-0.16.1
./configure --prefix=/usr/local/isl
make && make install
2.5 添加依赖的环境变量
代码语言:javascript复制vi ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/:/usr/local/isl/lib
source ~/.bashrc
把四项依赖的lib目录加入到/etc/ld.so.conf中
代码语言:javascript复制sudo ldconfig
需要重启系统,让环境变量生效!!! 3. 编译gcc
代码语言:javascript复制cd gcc-7.3.0
./configure --prefix=/usr/local/gcc-7.3.0 --enable-languages=c,c --disable-multilib --with-system-zlib --disable-multilib --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc --with-isl=/usr/local/isl
sudo make && make install
- 设置环境变量
在~/.bashrc文件中加入
export LD_LIBRARY_PATH=.../xxx/xxx/xxx/lib64
ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/163829.html原文链接:https://javaforall.cn