2013-08-12 wcdj (明天七夕,纪念结婚一周年)
1 下载最新支持C++11的GCC编译器
http://gcc.gnu.org/gcc-4.8/(下载gcc 4.8.1)
-
GCC 4.8.1 will be
C++11 feature-complete
[2013-04-01] Support for C++11
ref-qualifiers was added to the GCC 4.8 branch, making G++ the first C++ compiler to implement all the major language features of the C++11 standard. This functionality will be available in GCC 4.8.1. (注意并不是所有的新特性都支持)
2 编译遇到的问题
首先查看INSTALL说明:file:///Users/gerryyang/code/public/gcc-4.8.1/INSTALL/index.html,然后尝试编译:
sh-3.2#pwd
/Users/gerryyang/code/public/gcc-4.8.1
sh-3.2# ./configure --prefix=/usr/local/gcc-4.8.1/
checking build system type... x86_64-apple-darwin12.4.0
checking host system type... x86_64-apple-darwin12.4.0
checking target system type... x86_64-apple-darwin12.4.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
http://gcc.gnu.org/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.
OK,根据错误提示“configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.”下载依赖的packages,ftp路径也已提示我们“
ftp://gcc.gnu.org/pub/gcc/infrastructure/",可以分别从如下链接进行下载:
GMP 4.2+: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
MPFR 2.4.0+: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
MPC 0.8.0+: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
根据提示的顺序分别安装GMP,MPFR和MPC:
step1: ./configure --prefix=/usr/local/gmp-4.3.2; make install
<