linux操作系统gcc8的编译笔记
Posted 鱼酱2333
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux操作系统gcc8的编译笔记相关的知识,希望对你有一定的参考价值。
- 1.下载gcc8.3
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz
- 2.解压
tar xvf gcc-8.3.0.tar.xz
cd ~/gcc-8.3.0
- 3.运行 download_prerequisites 脚本
./contrib/download_prerequisites
- 3.1 运行download_prerequisites 脚本失败,查看/download_prerequisites.sh
//这是依赖的库
gmp='gmp-6.1.0.tar.bz2'
mpfr='mpfr-3.1.4.tar.bz2'
mpc='mpc-1.0.3.tar.gz'
isl='isl-0.18.tar.bz2'
想办法下载到根目录
-
- 建立输出目录,生成makefile
mkdir gcc-build-8.3.0
cd gcc-build-8.3.0
../configure --prefix=/home/app/gcc-8.3.0 --enable-shared --enable-threads=posix --enable-languages=c,c++,fortran --disable-multilib
# --prefix=/usr/local/gcc6 指定安装路径
# --enable-languages=c,c++ 支持的编程语言
# --enable-threads=posix 使用POSIX/Unix98作为线程支持库
# --disable-multilib 取消多目标库编译(取消32位库编译)
-
5.编译
make -j4 -
6.1安装到 …/configure --prefix =/home/tools/gcc-8.3.0里面
make install
- 6.2
- 7.版本检查
gcc -v
临时环境变量,这个不好使
export PATH=/home/yuch/tool/gcc-8.3.0/bin:$PATH
这种可以切换gcc版本编译
export CC=/home/yuch/tool/gcc-8.3.0/bin/gcc
export CXX=/home/yuch/tool/gcc-8.3.0/bin/g++
cmake ..
编译
../configure --prefix=/home/app/gcc-8.3.0 --enable-shared --enable-threads=posix --enable-languages=c,c++ --disable-multilib
--with-gmp=/usr/local/gmp-6.0.1 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3
--with-isl=/opt/gcc-8.3.0/isl-0.18
../gcc-4.7.2/configure --prefix=/usr/local/gcc-4.7 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++
- mpfr-3.1.4
../configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.0.1
- mpc-1.0.3
../configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-6.0.1 --with-mpfr=/usr/local/mpfr-3.1.4
./configure --prefix=/usr/local/isl-0.18 --with-gmp-prefix=/usr/local/gmp6.0.1/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.0.1/lib:/usr/local/mpfr-3.1.4/lib
../configure --prefix=/home/app/gcc-8.3.0 --with-gmp=/usr/local/gmp6.0.1 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3 --with-isl=/usr/local/isl-0.18 --enable-languages=c,c++ --disable-multilib
make -j 6
make install
以上是关于linux操作系统gcc8的编译笔记的主要内容,如果未能解决你的问题,请参考以下文章