您的位置:首页 > 其它

Ubuntu11.04安装Gcc4.4.1所出现的问题及解决方案

2013-11-22 15:02 417 查看
重要处均用粗体表示。

1.下载源码:http://mirror.bjtu.edu.cn/gnu/

2.解压 然后执行 ./configure

3.出现问题:

  configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+

  下载GMP MPFR: http://mirror.bjtu.edu.cn/gnu/
3.解压GMP MPFR并移入gcc-4.4.1然后继续执行./configure

4.出现问题:

  找不到gmp.h

5.安装GMP:

  进入gmp源码目录:

  执行./configure

  出现错误:configure: error: No usable m4 in $PATH or /usr/5bin

  安装m4

  


  然后继续执行./configure,成功。生成Makefile

  执行make&&make install&&make check

  同理,照此方法安装MPFR。

6.进入gcc-4.4.1解压目录,执行./configure ( 建议执行:./configure --prefix=/usr/local/gcc-4.4.1 --enable-threads=posix --disable-checking --enable--long-long --host=i386 --with-system-zlib --enable-languages=c,c++,java

7.执行make,出现问题:

  configure: error: cannot compute suffix of object files: cannot compile

  需要将gmp和mpfr目录加入到环境变量中,在/etc/profile文件末尾加上:export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib,注意修改目录,之后运行#source /etc/profile使其生效即可。因为gmp和mpfr默认安装的库路径为/usr/local/lib,所以只用添加即可。

8.继续执行make,出现错误:

  asm/errno.h:没有那个文件或目录

  因为/usr/include/目录下没有asm,只有asm-generic,故做一个软链接,执行:

  cd /usr/include
  sudo ln -s asm-generic asm

9.make成功,然后执行sudo make install

  出现错误:libmpfr.so.1: cannot open shared object file: No such file or directory

  执行:gedit /etc/ld.so.conf

     另起一行,添加该共享库的绝对路径:/usr/local/lib

     执行:ldconfig

10.安装成功,执行gcc -v 查看版本



注:最好执行gcc-4.4.1中的./configure时添加条件,否则编译时间将很长(花费我三四个小时。。)。

  2013-11-22 15:03:00

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: