linux编译安装gcc5.2,Linux编译安装GCC

1. 下载gcc和其依赖包,并按照以下顺序安装,其中--prefix可以根据自己的情况设置路径

./configure --prefix=/usr/local/gmp

make && make install

./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp

make && make install

./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp -with-mpfr=/usr/local/mpfr

make && make install

./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc --prefix=/usr/local/gcc

make -j

make install

2. 可能遇到的问题

1)问题:

../../gcc-aarch64-sve-acle-branch/gcc/hwint.h:62:5: error: #error "Unable to find a suitable type for HOST_WIDE_INT"

#error "Unable to find a suitable type for HOST_WIDE_INT"

^In file includedfrom ../../gcc-aarch64-sve-acle-branch/gcc/hash-table.h:243:0,from ../../gcc-aarch64-sve-acle-branch/gcc/coretypes.h:441,from ../../gcc-aarch64-sve-acle-branch/gcc/c/c-lang.c:23:

../../gcc-aarch64-sve-acle-branch/gcc/statistics.h:25:2: error: #error GATHER_STATISTICS must be defined

#error GATHER_STATISTICS must be defined

解决办法:去除CPLUS_INCLUDE_PATH设置

export CPLUS_INCLUDE_PATH=

2)问题:

configure: error: `CC'has changed since the previous run:

configure: former value: `x86_64-redhat-linux-gcc'configure: current value: `/home/lixuezd/local/gcc/./gcc/xgcc -B/home/lixuezd/local/gcc/./gcc/ -B/home/lixuezd/local/gcc/x86_64-redhat-linux/bin/ -B/home/lixuezd/local/gcc/x86_64-redhat-linux/lib/ -isystem /home/lixuezd/local/gcc/x86_64-redhat-linux/include -isystem /home/lixuezd/local/gcc/x86_64-redhat-linux/sys-include'configure: warning: ignoring whitespace changes in `CFLAGS'since the previous run:

configure: former value: `-g -O2'configure: current value: `-g -O2 'configure: error: `build_alias'has changed since the previous run:

configure: former value: `x86_64-unknown-linux-gnu'configure: current value: `x86_64-redhat-linux'configure: error: in `/home/lixuezd/local/gcc/fixincludes':

configure: error: changes inthe environment can compromise the build

configure: error: run `make distclean'and/or `rm ./config.cache'and start over

make[1]: *** [configure-fixincludes] Error 1make[1]: Leaving directory `/home/lixuezd/local/gcc'make: *** [all] Error 2

解决方法:

删掉gcc源码,重新建立gcc后再执行 ./configure .....,或者执行:make disclean和rm ./config.cache命令,我看着麻烦,还是 rm -fr gcc最简单。

这里要提的就是,如果配置发生了更新,如果没有清空上一次的结果,可能会遇上这个问题。

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页