升级g++详细步骤

 

转自http://blog.csdn.net/wayz11/article/details/7302210

 

1、下载gcc源码

对于只支持C++语言的编译,无需下载全代码包。可以只下载core源码和相应语言的源码包。

wget ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.6.2/gcc-core-4.6.2.tar.bz2

wget ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.6.2/gcc-g++-4.6.2.tar.bz2

2、解压到同一个目录

tar -jxvf gcc-core-4.6.2.tar.bz2

tar -jxvf gcc-g++-4.6.2.tar.bz2

 

源码将被加压到gcc-4.6.2目录中。

3、尝试./configure

cd gcc-4.6.2

./configure

报错如下:

  1. configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.  
  2. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify  
  3. their locations.  Source code for these libraries can be found at  
  4. their respective hosting sites as well as at  
  5. ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also  
  6. http://gcc.gnu.org/install/prerequisites.html for additional info.  If  
  7. you obtained GMP, MPFR and/or MPC from a vendor distribution package,  
  8. make sure that you have installed both the libraries and the header  
  9. files.  They may be located in separate packages.  

 

4、安装 GMP,MPFR和MPC

4.1、下载源码

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2

4.2、安装

解压

./configure

make

转自http://blog.csdn.net/wayz11/article/details/7302210

 

make install

注意安装顺序:首先安装GMP,其次安装MPFR,最后安装MPC。

5、编译G++

./configure

make

然后是漫长的等待,中间会报出很多警告:

warning: duplicate `const'
不用管它。继续等待。在我的虚拟机上大概跑了近两个小时。幸亏不是编译gcc全语言包。

6、安装验证

make install

使用 gcc -v 查看,顺利升级到4.6.2。大笑

posted @ 2012-04-16 17:57  iq50  阅读(545)  评论(0编辑  收藏  举报