ubuntu下如何编译GCC4.8

本文详细介绍了如何使用svn获取GCC源码,安装GMP、MPFR、MPC等依赖库,并提供了遇到编译错误时的解决方法。重点解决了编译GCC时出现的未定义引用错误,确保了编译过程顺利进行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


转载于:https://my.oschina.net/zhuanghaoren/blog/114305

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值