1、下载升级包所需软件
boost_1_60_0.tar.gz http://www.boost.org/users/history/version_1_60_0.html
gcc-4.8.0.tar.gz http://ftp.gnu.org/gnu/gcc/gcc-4.8.0/ 必须
isl-0.11.1.tar.gz http://isl.gforge.inria.fr/ 必须
mpc-1.0.3.tar.gz http://ftp.heanet.ie/mirrors/gnu/mpc/ 必须
cloog-0.18.1.tar.gz ftp://gcc.gnu.org/pub/gcc/infrastructure/ 必须
gmp-5.1.3.tar.gz http://ftp.yz.yamagata-u.ac.jp/pub/GNU/gmp/ 必须
libelf-0.8.13.tar.gz http://www.mr511.de/software/english.html 必须
mpfr-3.1.3.tar.gz http://ftp.gnu.org/gnu/mpfr/ 必须
2、依次安装相关的软件
Gmp
tar -jxvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
./configure –prefix=/usr/local/gmp
make -j 4 && make install && echo $?
Mpfr
tar -zxvf mpfr-3.1.3.tar.gz
cd mpfr-3.1.3
./configure –with-gmp-include=/usr/local/gmp/include \
–with-gmp-lib=/usr/local/gmp/lib \
–prefix=/usr/local/mpfr
make -j 4 && make install && echo $?
Mpc
tar -zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure –with-mpfr-include=/usr/local/mpfr/include \
–with-mpfr-lib=/usr/local/mpfr/lib \
–with-gmp-include=/usr/local/gmp/include \
–with-gmp-lib=/usr/local/gmp/lib \
–prefix=/usr/local/mpc
make -j 4 && make install && echo $?
Isl
tar -zxvf isl-0.11.tar.gz
cd isl-0.11
./configure –with-gmp-prefix=/usr/local/gmp –prefix=/usr/local/isl
make -j 4 && make install && echo $?
Cloog
tar -zxvf cloog-0.18.0.tar.gz
cd cloog-0.18.0
./configure –with-gmp-prefix=/usr/local/gmp \
–with-isl-prefix=/usr/local/isl \
–prefix=/usr/local/cloog
make -j 4 && make install && echo $?
Gcc
tar -zxvf gcc-4.8.0.tar.gz
cd gcc-4.8.0
编译安装 gcc 是需要指定各个依赖库的文件目录
vi /etc/ld.so.conf
/usr/local/isl/lib
/usr/local/cloog/lib
/usr/local/mpc/lib
/usr/local/mpfr/lib
/usr/local/gmp/lib
保存、退出后执行命令 ldconfig
./configure \
–with-mpfr=/usr/local/mpfr \
–with-gmp=/usr/local/gmp \
–with-mpc=/usr/local/mpc \
–with-mpfr-include=/usr/local/mpfr/include \
–with-mpfr-lib=/usr/local/mpfr/lib \
–with-gmp-lib=/usr/local/gmp/lib \
–with-gmp-include=/usr/local/gmp/include \
–with-mpc-lib=/usr/local/mpc/lib \
–with-mpc-inclue=/usr/local/mpc/include \
–with-isl-include=/usr/local/isl/include \
–with-isl-lib=/usr/local/isl/lib/ \
–with-cloog-include=/usr/local/cloog/include \
–with-cloog-lib=/usr/local/cloog/lib \
–enable-languages=c,c++,objc,fortran,obj-c++,java \
–enable-threads=posix \
–disable-multilib \
–with-pkgversion=’SUSE Linux’
make -j 4 && make install && echo $?
3、验证
gcc -v
4、报错解决
1)解压 gcc 安装包直接编译
错误信息:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.Try the –with-gmp, –with-mpfr and/or –with-mpc options to specify their locatio
错误原因:
对 gcc 源码编译安装,需要 GMP 4.2+,MPFR 2.4.0+ and MPC 0.8.0+ 的事先安装,如果检测不到默认头文件和库文件里存在上述安装包文件,则会报错。
解决方案:
通过安装 gmp,mpfr,mpc 安装包,并指定其库文件路径进行编译 gcc 即可,具体版本和安装步骤详细参考上述安装步骤。
安装 gmp,mpfr,mpc 后执行下面编译脚本进行编译
./configure –with-mpfr=/usr/local/mpfr –with-gmp=/usr/local/gmp –with-mpc=/usr/local/mpc –with-mpfr-include=/usr/local/mpfr/include –with-mpfr-lib=/usr/local/mpfr/lib –with-gmp-lib=/usr/local/gmp/lib –with-gmp-include=/usr/local/gmp/include –with-mpc-lib=/usr/local/mpc/lib –with-mpc-inclue=/usr/local/mpc/include –enable-languages=c,c++ –enable-threads=posix –disable-multilib
2)编译 mpc 安装包出错
错误信息:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libmpfr.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libmpc.la] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3/src’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3′
make: *** [all] Error 2
错误原因:
编译 mpc 源码时,没有指定 gmp、mpfr 对应的安装路径(主要是库文件和头文件路径)
解决方案:
在编译脚本里加入相应的 gmp、mpfr 安装路径或者库文件 + 头文件路径
./configure –with-mpfr-include=/usr/local/mpfr/include –with-mpfr-lib=/usr/local/mpfr/lib –with-gmp-include=/usr/local/gmp/include –with-gmp-lib=/usr/local/gmp/lib –prefix=/usr/local/mpc
或者
./configure –with-mpfr=/usr/local/mpfr –with-gmp=/usr/local/gmp –prefix=/usr/local/mpc
3)带 gmp、mpfr、mpc 编译参数,编译 gcc 源码出错
错误信息:
conftest.c:10:25: error: isl/version.h: No such file or directory
错误原因:
没安装 isl 安装包
解决方案:
安装 isl-0.11.1.tar.gz, 具体安装步骤参照上面内容。
4)源码编译 isl 出错
错误信息:
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions’
collect2: ld returned 1 exit status
make[2]: *** [isl_cat] Error 1
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions’
collect2: ld returned 1 exit status
make[2]: *** [isl_polyhedron_detect_equalities] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/isl-0.12.2′
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/isl-0.12.2′
make: *** [all] Error 2
错误原因:
isl 编译安装,需要在指定 gmp 的安装路径
解决方案:
在编译参数里指定 gmp 的安装路径,并且格式为 –with-gmp-prefix==,不能用 –with-gmp
./configure –with-gmp-prefix=/usr/local/gmp –prefix=/usr/local/isl
参考文件:https://groups.google.com/forum/#!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ
5)安装完 gmp,mpfr,mpc,isl 后,源码编译 gcc 出错
错误信息:
configure:6098: gcc -c -g -O2 -DCLOOG_INT_GMP -I/usr/local/isl/include -I/usr/local/gmp/include -I/usr/local/mpfr/include -I/usr/local/mpc/include conftest.c >&5
conftest.c:10:27: error: cloog/version.h: No such file or directory
conftest.c: In function ‘main’:
conftest.c:15: error: ‘choke’ undeclared (first use in this function)
conftest.c:15: error: (Each undeclared identifier is reported only once
conftest.c:15: error: for each function it appears in.)
conftest.c:15: error: expected ‘;’ before ‘me’
错误原因:
缺少安装包 cloog,没找到相应的库文件。
解决方案:
安装 cloog-0.18.1.tar.gz,具体安装步骤参照上面安装步骤,安装 cloog 后,继续编译 gcc
./configure –with-mpfr=/usr/local/mpfr –with-gmp=/usr/local/gmp –with-mpc=/usr/local/mpc –with-mpfr-include=/usr/local/mpfr/include –with-mpfr-lib=/usr/local/mpfr/lib –with-gmp-lib=/usr/local/gmp/lib –with-gmp-include=/usr/local/gmp/include –with-mpc-lib=/usr/local/mpc/lib –with-mpc-inclue=/usr/local/mpc/include –with-isl-include=/usr/local/isl/include –with-isl-lib=/usr/local/isl/lib/ –with-cloog-include=/usr/local/cloog/include –with-cloog-lib=/usr/local/cloog/lib –enable-languages=c,c++ –enable-threads=posix –disable-multilib –disable-bootstrap –disable-libstdcxx-pch
6)安装 cloog 遇到下属错误
错误信息:
./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
错误原因:
找不到 isl 的库文件,需要在 /etc/ld.so.conf 中添加以下内容 /usr/local/isl/lib,并通过 ldconfig 使其生效。
解决方案:
通过 LD_LIBRARY_PATH 指定 isl 库文件路径或者在 /etc/ld.so.conf 中添加以下内容 /usr/local/isl/lib,并通过 ldconfig 使其生效。然后通过相应的编辑参数指定 isl 的库文件和头文件,进行 cloog 编译安装。通过 strings /etc/ld.so.cache | grep libisl 查看是否已经将库文件写入缓存。
7) 下属错误可以忽略
错误信息 01:
conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
8) 下属错误可以忽略
错误信息:
ldconfig: /usr/local/isl/lib/libisl.so.10.1.0-gdb.py is not an ELF file – it has the wrong magic bytes at the start.
错误原因:
/usr/local/isl/lib/libisl.so.10.1.0-gdb.py 文件类型错误
解决方案:
rm /usr/local/isl/lib/libisl.so.10.1.0-gdb.py
5、参考文档
http://stackoverflow.com/questions/9450394/how-to-install-gcc-piece-by-piece-with-gmp-mpfr-mpc-elf-without-shared-libra
https://groups.google.com/forum/#!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ