Fedora16下编译安装GCC 4.7

来源:互联网 发布:2014知乎热门精选 编辑:程序博客网 时间:2024/05/16 18:40
GCC4.7版本增强了C++11的支持,但Fedora16的GCC版本却迟迟不能升级到GCC4.7,只好自己编译安装


GCC的编译安装指导可以参考http://gcc.gnu.org/install/


一,编译准备:http://gcc.gnu.org/install/prerequisites.html
参考该文档,在编译GCC之前需安装以下依赖库
MPFR Library version 2.4.2 (or later)

Necessary to build GCC. It can be downloaded from http://www.mpfr.org/. If an MPFR source distribution is found in a subdirectory of your GCC sources named mpfr, it will be built together with GCC. Alternatively, if MPFR is already installed but it is not in your default library search path, the --with-mpfr configure option should be used. See also --with-mpfr-lib and --with-mpfr-include. 


MPC Library version 0.8.1 (or later)

Necessary to build GCC. It can be downloaded from http://www.multiprecision.org/. If an MPC source distribution is found in a subdirectory of your GCC sources named mpc, it will be built together with GCC. Alternatively, if MPC is already installed but it is not in your default library search path, the --with-mpc configure option should be used. See also --with-mpc-lib and --with-mpc-include. 


Parma Polyhedra Library (PPL) version 0.11
Necessary to build GCC with the Graphite loop optimizations. It can be downloaded from http://www.cs.unipr.it/ppl/Download/.

The --with-ppl configure option should be used if PPL is not installed in your default library search path. 


CLooG-PPL version 0.15 or CLooG 0.16

Necessary to build GCC with the Graphite loop optimizations. There are two versions available. CLooG-PPL 0.15 as well as CLooG 0.16. The former is the default right now. It can be downloaded from ftp://gcc.gnu.org/pub/gcc/infrastructure/ as cloog-ppl-0.15.tar.gz.


CLooG 0.16 support is still in testing stage, but will be the default in future GCC releases. It is also available at ftp://gcc.gnu.org/pub/gcc/infrastructure/ as cloog-0.16.1.tar.gz. To use it add the additional configure option --enable-cloog-backend=isl. Even if CLooG 0.16 does not use PPL, PPL is still required for Graphite.
In both cases --with-cloog configure option should be used if CLooG is not installed in your default library search path.

还好根据这些库的源码编译比较简单,只是CLooG-PPL需用./configure --with-ppl=/path的方式,否则编译的时候会出现“source/../include/cloog/cloog.h:47:30: error:”的错误 polylib/missing.h: No such file or directory


另外,需要安装glibc-devel.i686(yum install glibc-devel.i686),否则编译阶段有可能遇到如下错误
In file included from /usr/include/features.h:387:0,
                 from /usr/include/stdio.h:28,
                 from ../../../../libgcc/../gcc/tsystem.h:88,
                 from ../../../../libgcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:7:27: 致命错误:gnu/stubs-32.h:没有那个文件或目录
编译中断。
make[5]: *** [_muldi3.o] 错误 1
make[5]: 离开目录“/opt/gcc/build/x86_64-redhat-linux/32/libgcc”
make[4]: *** [multi-do] 错误 1


二,配置编译

解压源代码,并建立build目录,进入build目录进行配置

在现有GCC版本基础上就可以看到当前GCC版本的配置编译选项,如下:

# gcc -v

../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id--enable-languages=c,c++,objc,obj-c++ --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux


三,编译和安装
make

make install



原创粉丝点击