Fedora16下編譯安裝GCC 4.7

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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章