重要:https://gcc.gnu.org/install/prerequisites.html 官方安装所需要的工具文档
还有就是这篇文章 http://blog.51cto.com/2716255/1965617 由于要安装一高可用软件,其在编译安装的时候提示需要4.+版本以上的gcc,而我的系统是rhel5.,gcc版本是gcc version 4.1.,因此需要将gcc版本升级,看似简单的升级,实施起来还是颇为曲折,仅将个人安装过程记录下来,希望对有需要的人有所帮助。
gcc的升级有多种方式可以完成,最简单的方式就是通过在线yum源的方式完成升级,其次是通过本地yum源做升级,还有可以通过rpm包升级以及源码包升级的方式。由于我这内网机,而且受限于系统版本和依赖包,通过本地yum和rpm也不是特别现实(比较繁琐),所以首选的方案是通过源码包升级。具体升级步骤如下:
、下载升级包所需软件 boost_1_60_0.tar.gz http://www.boost.org/users/history/version_1_60_0.html
gcc-4.8..tar.gz http://ftp.gnu.org/gnu/gcc/gcc-4.8.0/ 必须
isl-0.11..tar.gz http://isl.gforge.inria.fr/ 必须
mpc-1.0..tar.gz http://ftp.heanet.ie/mirrors/gnu/mpc/ 必须
cloog-0.18..tar.gz ftp://gcc.gnu.org/pub/gcc/infrastructure/ 必须
gmp-5.1..tar.gz http://ftp.yz.yamagata-u.ac.jp/pub/GNU/gmp/ 必须
libelf-0.8..tar.gz http://www.mr511.de/software/english.html
mpfr-3.1..tar.gz http://ftp.gnu.org/gnu/mpfr/ 必须 、依次安装相关的软件
)boost安装(可不装)
tar -xzvf boost_1_60_0.tar.gz
cd boost_1_60_0
./bootstrap.sh
./b2
./bjam install
)gmp安装
tar -xzv gmp-5.1..tar.gz
cd gmp-5.1.
./configure --prefix=/usr/local/gmp
make
make install
)mpfr安装
tar -xzvf mpfr-3.1..tar.gz
cd mpfr-3.1.
./configure --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpfr
make
make install
)mpc安装
tar -xzvf mpc-1.0..tar.gz
cd mpc-1.0.
./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
make install
)isl安装
tar -xzvf isl-0.11..tar.gz
cd isl-0.11.
./configure --with-gmp-prefix==/usr/local/gmp --prefix=/usr/local/isl
make
make install
)cloog安装
tar -xzvf cloog-0.18..tar.gz
cd cloog-0.18.
./configure --with-gmp-prefix==/usr/local/gmp -with-isl-prefix=/usr/local/isl --prefix=/usr/local/cloog
make
make install
)gcc安装
tar -xzvf gcc-4.8..tar.gz
cd gcc-4.8.
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++ --enable-threads=posix --disable-multilib
make
make install
、安装后校验
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8./lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog=/usr/local/cloog --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 4.8. (GCC) 、安装过程错误信息以及解决方案
)解压gcc安装包直接编译
错误信息:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.+ and MPC 0.8.+.Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locatio
错误原因:
对gcc源码编译安装,需要GMP 4.2+,MPFR 2.4.+ and MPC 0.8.+的事先安装,如果检测不到默认头文件和库文件里存在上述安装包文件,则会报错。
解决方案:
通过安装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 )编译mpc安装包出错
错误信息:
/usr/lib/gcc/x86_64-redhat-linux/4.1./../../../../lib64/libmpfr.a: could not read symbols: Bad value
collect2: ld returned exit status
make[]: *** [libmpc.la] Error
make[]: Leaving directory `/tools/PXC/gcc/mpc-1.0./src'
make[]: *** [all-recursive] Error
make[]: Leaving directory `/tools/PXC/gcc/mpc-1.0.'
make: *** [all] Error
错误原因:
编译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
)带gmp、mpfr、mpc编译参数,编译gcc源码出错
错误信息:
conftest.c::: error: isl/version.h: No such file or directory
错误原因:
没安装isl安装包
解决方案:
安装isl-0.11..tar.gz,具体安装步骤参照上面内容。
)源码编译isl出错
错误信息:
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned exit status
make[]: *** [isl_cat] Error
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned exit status
make[]: *** [isl_polyhedron_detect_equalities] Error
make[]: Leaving directory `/tools/PXC/gcc/isl-0.12.'
make[]: *** [all-recursive] Error
make[]: Leaving directory `/tools/PXC/gcc/isl-0.12.'
make: *** [all] Error
错误原因:
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
)安装完gmp,mpfr,mpc,isl后,源码编译gcc出错
错误信息:
configure:: 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 >&
conftest.c::: error: cloog/version.h: No such file or directory
conftest.c: In function 'main':
conftest.c:: error: 'choke' undeclared (first use in this function)
conftest.c:: error: (Each undeclared identifier is reported only once
conftest.c:: error: for each function it appears in.)
conftest.c:: error: expected ';' before 'me'
错误原因:
缺少安装包cloog,没找到相应的库文件。
解决方案:
安装cloog-0.18..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
)安装cloog遇到下属错误
错误信息:
./conftest: error while loading shared libraries: libisl.so.: 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 查看是否已经将库文件写入缓存。 )下属错误可以忽略
错误信息01:
conftest.cpp::: error: #error -static-libstdc++ not implemented 、参考文档:
http://*.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
在Linux系统上安装isl-.18版本
http://blog.sina.com.cn/s/blog_15d0344a30102xjyz.html
......第二次还是没成功 ,,,,以后再来搞吧