免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2479 | 回复: 0
打印 上一主题 下一主题

ubuntu 9.04 编译安装gcc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-07 19:20 |只看该作者 |倒序浏览

                                                                                前两天开始动手,想弄个gcc4.4玩玩,在网上google了一下,首先急匆匆的把源码给弄下来了,用的是svn:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc
首先找了个安装指南,地址在:http://gcc.gnu.org/install/
下面描述我的安装过程(系统:ubuntu9.04 x86_64,现有gcc版本:系统自带的4.3.3版本)
按照上面的指南的步骤,扫了一眼prerequistes,直接跳过(或许这是造成后面麻烦的原因之一吧)
然后开始配置,首先跳出gcc源码的顶层目录,建立gccobj目录,进入之后,第一次选择默认选项,所以,直接../gcc/configure
没跑两步就出问题了,看了下出错信息,恩,权限不够,于是乎改成sudo ../gcc/configure,还是不行,提示缺GMP, MPFR
马上sudo apt-get install GMP, MPFR, 无法找到安装包,换用小写依然一样,无奈之下google之,下载了其源码文件,按照里头的INSTALL文件提示安装完毕,源码文件可以在下面的地址下载:
http://www.multiprecision.org/
重新configure,终于顺利配置完毕,生成makefile文件
然后make,继续权限错误,继续sudo……
事情的发展总是那么不尽如人意,没多久出现第一个错误:
gcc: gengtype-lex.c: No such file or directory
google之,找到答案,需要安装bison 与 flex
于是sudo apt-get install bison flex,再一次sudo make,依然出现同样的错误,抓狂了……
再一次google无果后,焦燥中扫了一眼出错信息,发现前面有一个warning,号称是没装flex,恩,莫非是需要重新configure?试试吧,重新弄了一次,同时增加了两个选项:
sudo ../gcc/configure --enable-bootstrap --enable-stage1-languagegs=c,c++
果然再一次sudo make时不再出现上面的错误,编译时间持续了一段时间,俺开始窃喜,恩,看来搞定了
事实无情的打击了我,编译工作再一次报错退出, 错误是:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
于是cat /usr/include/gnu/stubs.h,发现在定义了__x86_64__时,应该include的是stubs-64.h,我的系统里压根就没有stubs-32.h这个文件,当时就有冲动直接把stubs-64.h 文件名字改成32,编译完成后改回来,想一想,还是google一下吧,果然有更好的办法:
http://ubuntuforums.org/archive/index.php/t-370114.html
仔细的读完全篇,首先把CFLAGS设为-m64并且声明为环境变量,之后安装libc-dev-i386:
CFLAGS=-m64; export CFLAGS
sudo apt-get install libc-dev-i386
重新configure,问题解决,并且没有跟楼主一样使用--disable-multilib选项
但是挫折并没有结束,编译运行了近一个半小时后依然报错退出,
使用sudo make >make.log,屏幕显示错误信息如下:
WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.
make[7]: *** [cp-tools.info] 错误 1
make[6]: *** [all-recursive] 错误 1
Makefile:860: 警告:覆盖关于目标“gjdoc”的命令
Makefile:778: 警告:忽略关于目标“gjdoc”的旧命令
Makefile:860: 警告:覆盖关于目标“gjdoc”的命令
Makefile:778: 警告:忽略关于目标“gjdoc”的旧命令
make[5]: *** [all-recursive] 错误 1
make[4]: *** [all-recursive] 错误 1
make[3]: *** [multi-do] 错误 1
make[2]: *** [all-multi] 错误 2
make[1]: *** [all-target-libjava] 错误 2
make: *** [all] 错误 2
太困了,明天继续
继续google,按照网友提示,增加了一个环境变量:
export LC_ALL=C
http://www.linuxsir.org/bbs/thread342943.html
同时将configure参数的改为:
sudo ../gcc/configure --enable-bootstrap --enable-languagegs=c,c++
继续make,上一个错误消除,但是继续产生新错误,崩溃ing
/stl_algobase.h:1152:32: fatal error: parallel/algobase.h: No such file or directory
compilation terminated.
make[4]: *** [parallel_list.lo] Error 1
make[4]: Leaving directory `/home/min/src/download/gccobj/x86_64-unknown-linux-gnu/libstdc++-v3/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/min/src/download/gccobj/x86_64-unknown-linux-gnu/libstdc++-v3'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/min/src/download/gccobj/x86_64-unknown-linux-gnu/libstdc++-v3'
make[1]: *** [all-target-libstdc++-v3] Error 2
make[1]: Leaving directory `/home/min/src/download/gccobj'
make: *** [all] Error 2
在系统内搜索了一下parallel/algobase.h,发现其是c++的头文件,位于/usr/include/c++/4.3.3/中,郁闷了,重新configure,添加--enable-build-with-cxx选项:
sudo ../gcc/configure --enable-bootstrap --enable-languages=c,c++ --enable-build-with-cxx
还是出现错误:
Configuring stage 1 in ./intl
configure: loading cache ./config.cache
configure: error: `CFLAGS' has changed since the previous run:
configure:   former value:  `-g -fkeep-inline-functions'
configure:   current value: `-g'
configure: error: in `/home/min/src/download/gccobj/intl':
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm ./config.cache' and start over
make[2]: *** [configure-stage1-intl] Error 1
make[2]: Leaving directory `/home/min/src/download/gccobj'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/min/src/download/gccobj'
make: *** [all] Error 2
执行:make distclean,权限不够,使用sudo
依然错误,无奈,选择另一条路,先设定环境变量CPPFLAGS
export CPPFLAGS="-I /usr/include/c++/4.3.3"
重新configure并make
终于成功了~~~~
之后就简单了,按照安装说明
sudo make DESTDIR=/usr/local install
结果装在了/usr/local/usr/local中,郁闷的删除,重新sudo make install,好了
后来的事实证明,还不如就保持第一次安装的样子,第二次的安装使得以后如果想删除将很困难
运行 /usr/local/bin/g++ --version:
g++ (GCC) 4.5.0 20091103 (experimental)
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
似乎不是4.4版本,无所谓了,svn下载的嘛
写个hello world程序验证:
#include
int main(int argc, char* argv[])
{
    std::cout
               
               
               
               
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/105027/showart_2089037.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP