您的位置:首页 > 其它

RHEL5.4 x86_64 GCC 4.1.2 升级到4.7.0版过程

2015-02-27 11:56 483 查看


RHEL5.4 x86_64 GCC 4.1.2 升级到4.7.0版过程(含安装MPFR、GMP、MPC过程)

(2012-05-28 21:02:00)


转载▼

RHEL5.4 x86_64 GCC 4.1.2 升级到4.7.0版过程

(含安装MPFR、GMP、MPC过程)

GCC(GNU Compiler Collection,GNU编译器套装),是一套由 GNU 开发的编程语言编译器。它是一套以 GPL 及 LGPL 许可证所发行的自由软件,也是 GNU计划 的关键部分, GCC(特别是其中的C语言编译器)也常被认为是跨平台编译器的事实标准。GCC 原名为 GNU C 语言编译器(GNU C Compiler),因为它原本只能处理 C语言。GCC 很快地扩展,变得可处理 C++。之后也变得可处理 Fortran、Pascal、Objective-C、Java, 以及 Ada
与其他语言。

GCC 首个公开发布版本是在 1987 年由 Richard Stallman 发布的,到今天已经整整 25 年了。为了庆祝 25 周年,GCC 也相应发布了 GCC 4.7.0 版本,这是 GCC 一个全新的重要版本。可以在GCC的官方网站http://gcc.gnu.org/ 下载到各个版本。

可惜的是RHEL5.4 x86_64系统自带的GCC版本是4.1.2版本(20080704发布), 已经远不能满足软件开发或使用的进度,因此需要升级至较新版本,本文以GCC4.7.0为例,介绍GCC升级的一般方法。

一、在安装前,需要先安装 MPFR 、GMP 和MPC

GCC编译需要mpfr和mpc(-->gmp、-->mpfr)库的支持,依次安装这几个库,其中mpfr可直接安装,安装mpc依赖mpfr和gmp库(对版本有要求,建议安装最新版本),然后configure时指定mpfr和gmp的include、lib路径。

下载 MPFR (mpfr-2.3.0), MPFR_patch、GMP (gmp-4.3.2) 和MPC(mpc-0.8.1),

安装过程是先安装 gmp,然后再安装 mpfr.和mpc

1、 安装gmp

注:安装均在root权限下进行:

[phamlab@Server ~]$ su –

Password:

[root@Server ~]# cd /home/phamlab/software/gcc_install/

[root@Server gcc_install]# ls

[root@Server gcc_install]# tar jxvf gmp-4.3.2.tar.bz2

[root@Server gcc_install]# cd gmp-4.3.2

[root@Server gmp-4.3.2]# ./configure

[root@Server gmp-4.3.2]# make

[root@Server gmp-4.3.2]# make check

这一步是必要的,用来查看有没有文件不匹配或缺失,在最后提示,到时注意看有没有 Error 之类的提示,如果没有则说明安装正常.

[root@Server gmp-4.3.2]# make install

安装编译后的软件,完成了安装过程

有必要说明程序的头文件(.h)和库文件(lib*)的位置, 本次安装会安装在 /usr/local/include 和/usr/local/lib 这个对后面安装 mpfr 很有作用.

2、 安装 mpfr

[root@Server gmp-4.3.2] cd ..

[root@Server gcc_install]# tar jxvf mpfr-2.4.2.tar.bz2

[root@Server gcc_install]# cd mpfr-2.4.2

[root@Server mpfr-2.4.2]# ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib

[root@Server mpfr-2.4.2]# make

[root@Server mpfr-2.4.2]# make check

如果出现如下信息

====================

All 156 tests passed

====================

make[2]: Leaving directory `/ tmp/mpfr-2.4.2/tests'

make[1]: Leaving directory `/ tmp/mpfr-2.4.2/tests'

make[1]: Entering directory `/tmp/mpfr-2.4.2'

make[1]: Nothing to be done for `check-am'.

make[1]: Leaving directory `/ tmp/mpfr-2.4.2

说明编译成功了.

接下来安装

[root@Server mpfr-2.4.2]# make install

3、 安装 MPC

[root@Server mpfr-2.4.2] cd ..

[root@Server gcc_install]# tar zxvf mpc-0.8.1.tar.gz

[root@Server gcc_install]# cd mpc-0.8.1

[root@Server mpc-0.8.1]# vi ./src/acos.c +192

注释掉第192行(# :rnd_im == GMP_RNDA ? GMP_RNDZ)即在该行前面加“#”

[root@Server mpc-0.8.1]# ./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib

[root@Server mpc-0.8.1]# make

[root@Server mpc-0.8.1]# make check (这个时候可能会有错误,但是这个没有关系,可以跳过!)

[root@Server mpc-0.8.1]# make install

二、安装gcc 4.7.0

1、配置gmp和mpfr的库文件路径, 在.bash_profile(一般在/root 目录下)配置 LD_LIBRARY_PATH,把 GMP 与 MPFR对应的 lib 配置上.

[root@Server mpc-0.8.1]# cd

[root@Server ~]# vi .bash_profile

export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

wq保存退出。

重启terminal生效或者使用 source /root/.bash_profile

[root@Server ~]# source .bash_profile

2、安装gcc

[root@Server ~]# cd /home/phamlab/software/gcc_install/

[root@Server gcc_install]# tar zxvf gcc-4.7.0.tar.gz

[root@Server gcc_install]# cd gcc-4.7.0

[root@Server gcc_install]# mkdir gcc_temp

[root@Server gcc_install]# cd gcc_temp

[root@Server gcc_temp]# ../configure --prefix=/usr --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local

[root@Server gcc_temp]# make

[root@Server gcc_temp]# make install

[root@Server gcc_temp]# gcc –v

gcc version 4.7.0 (GCC)

备注:

1、 MPFR: 一个多精度高效的浮点计算C语言库, 基于GMP .-The MPFR library is a C library for multiple-precision floating-point computations with correct rounding. MPFR has continuously been supported by the INRIA and the current main authors come from the CACAO and Arénaire
project-teams at Loria (Nancy, France) and LIP (Lyon, France) respectively see more on the credit page. MPFR is based on the GMP multiple-precision library.

2、 GMP:计算任意精度的数学库, 包括支持整数,有理数和浮点. GMP包括大量的接口函数.-GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied
by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.

3、 MPC:gnu交叉编译器配置时需要的-gnu cross-compiler configuration needed
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: