ubuntu下如何编译GCC4.8

1.获取源码:

svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir

2.安装GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+:

下载地址: ftp://gcc.gnu.org/pub/gcc/infrastructure/ 

  • 安装GMP:
         编译方法:./configure 

                       make

                       make check

                       sudo make install

    安装MPFR:

       编译方法: ./configure 

                        make

                        make check

                       sudo make install

    安装MPC:

      编译方法: ./configure 

                        make

                        make check

                       sudo make install

3. ./configure 

如果出现一下错误,说明你没有安装好上面3个库。

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.
4.make 

编译需要很长时间。。。

过程如果出现以下类似错误:

c-ada-spec.c:(.text+0x8d6d): undefined reference to `tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)'
c-ada-spec.c:(.text+0x8d95): undefined reference to `tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)'
c-ada-spec.c:(.text+0x8dbd): undefined reference to `tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)'
c-ada-spec.c:(.text+0x8de5): undefined reference to `tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)'
c-ada-spec.c:(.text+0x8e0d): undefined reference to `tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)'
说明你没有安装clang编译器,编译gcc4.8要求clang3.0以上,通过sudo apt-get 获取的是的2.8的版本。

所以到官网下载去:http://llvm.org/releases/download.html#3.2

直接下载二进制文件,懒得自己编译了,我下载的是ubuntu12.04版本。下载后直接安装。

5.sudo make instal


你可能感兴趣的:(ubuntu,gcc4.8)