【问题标题】:What is the issue with Ubuntu (12.10) and GCC 4.7/4.8?Ubuntu (12.10) 和 GCC 4.7/4.8 有什么问题?
【发布时间】:2013-04-01 04:26:28
【问题描述】:

由于 GCC 和 Ubuntu 的多个版本,我遇到了安装 GCC 所需的几个头文件和目标文件的路径和命名问题。

描述:在安装 ubuntu(例如在我的情况下是 12.04)并安装 gcc 的所有先决条件后,我运行以下命令:

sudo mkdir /usr/local/stow/gcc-4.8.0
./configure --prefix /usr/local/stow/gcc-4.8.0
make
sudo make install

为了完整起见,剩下的安装过程:

cd /usr/local/stow
sudo stow -t /usr/local/ gcc-4.8.0
gcc -v

但是,这种简单而正确的 gcc 安装方法在“制作”步骤中存在一些问题,并显示以下错误消息:

1.) 'stubs.h' 的问题

/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory

可以通过将以下命令添加到 ~/.bashrc 来修复:

if [ -z "$CPATH"]; then
        export CPATH="/usr/include/i386-linux-gnu"
else
        export CPATH=$CPATH:"/usr/include/i386-linux-gnu"
fi

2.) 'crti.o'、'crtn.o' 和 'crt1.o' 的问题

/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find crtn.o: No such file or directory
/usr/bin/ld: cannot find crt1.o: No such file or directory

这可以用非常丑陋的解决方案来解决:

sudo ln -s /usr/lib/i386-linux-gnu/crti.o /usr/lib/i386-linux-gnu/crtn.o /usr/lib/i386-linux-gnu/crt1.o /usr/lib

因为 - 我不知道为什么 - 以下命令在“sudo make install”的链接步骤中没有解决问题

if [ -z "$LIBRARY_PATH"]; then
    export LIBRARY_PATH="/usr/lib/${multiarch}"
else
    export LIBRARY_PATH=$LIBRARY_PATH:"/usr/lib/${multiarch}"
fi

if [ -z "$LD_LIBRARY_PATH"]; then
    export LD_LIBRARY_PATH="/usr/lib/${multiarch}"
else
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/lib/${multiarch}"
fi

(通过这些解决方案,我可以在 Ubuntu 12.04 上编译 GCC-4.7.2。 - 我在 Ubuntu 12.04 上编译 GCC-4.8.0 时仍然遇到问题,但这是不同的主题。)

我的问题是:有人知道我们遇到这些问题的原因/背景吗?有人知道合适的解决方案吗? (对于“适当的解决方案”,我的意思是一种不需要设置环境变量或将符号链接库链接到不同目录的解决方案。对我来说,这些更改很难看,因为它们需要对系统进行更改,而这些更改可能无法追溯或重做。)

【问题讨论】:

    标签: gcc ubuntu compilation ubuntu-12.04 gcc4.7


    【解决方案1】:

    这些是我在 Ubuntu 12.04 上编译 GCC 4.8.0 时遇到的问题。

    这可能会对你有所帮助。

    在 ubuntu 12.04 上编译 GCC 4.8 的编译指南

    错误 1

    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.
    

    解决方案

    1. 下载并安装gmp版本>=4.3.2包因为mpc需要更高版本
      • 从 gmplib.org 下载源代码
      • 编译源代码并安装
      • 编译 gmp 时,请参阅 ERROR 2 以获得帮助
      • 已安装 gmp 版本 5.1.1
    2. 下载并安装mpfr包
      • 已安装 mpfr 版本 3.1.2
    3. 下载并安装mpc包
      • 已安装 mpc 1.0 版

    从以下位置下载软件包 http://ftp.gnu.org


    错误 2

    Error while compiling gmp library
    
    checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin
    

    解决方案

    sudo apt-get install m4 
    

    http://ubuntuforums.org/showthread.php?t=850491


    错误 3

    Cannot find g++ compiler
    

    我收到这个错误是因为我最近安装了操作系统并且没有安装编译器。

    解决方案

    sudo apt-get install build-essential
    

    这将安装所有标准构建必备软件


    错误 4

    checking for i686-pc-linux-gnu-gcc... /home/suhastheju/projects/gcc/gcc-4.8.0/host-i686-pc-linux-gnu/gcc/xgcc -B/home/suhastheju/projects/gcc/gcc-4.8.0/host-i686-pc-linux-gnu/gcc/ -B/usr/local/i686-pc-linux-gnu/bin/ -B/usr/local/i686-pc-linux-gnu/lib/ -isystem /usr/local/i686-pc-linux-gnu/include -isystem /usr/local/i686-pc-linux-gnu/sys-include   
    checking for suffix of object files... configure: error: in `/home/suhastheju/projects/gcc/gcc-4.8.0/i686-pc-linux-gnu/libgcc':
    configure: error: cannot compute suffix of object files: cannot compile
    See `config.log' for more details.
    make[2]: *** [configure-stage1-target-libgcc] Error 1
    make[2]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0'
    make[1]: *** [stage1-bubble] Error 2
    make[1]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0'
    make: *** [all] Error 2
    

    解决方案

    虽然 gcc 文档有说明,但我们可以提供 gmp 的路径 和 mpfr 通过 –with-gmp 和 –with-mpfr 标志安装, 但不幸的是,我试图给出路径但它没有用。

    我没有资格说最后一句话,这个,它是否是一个错误 在构建脚本或其他东西中,但下面是问题的解决方案。

    在构建时,在LD_LIBRARY_PATH环境中添加gmp和mpfr安装路径 多变的。执行以下操作 导出 LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

    如果您有不同路径中的库,请添加库所在的路径


    错误 5

    libbackend.a(tree-vect-data-refs.o):tree-vect-data-refs.c:(.text+0x87da): more undefined references to `vector_type_mode(tree_node const*)' follow
    collect2: error: ld returned 1 exit status
    make[3]: *** [cc1] Error 1
    make[3]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0/host-i686-pc-linux-gnu/gcc'
    make[2]: *** [all-stage2-gcc] Error 2
    make[2]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0'
    make[1]: *** [stage2-bubble] Error 2
    make[1]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0'
    make: *** [all] Error 2
    

    解决方案

    从头重新编译源代码,效果神奇

    make clean all
    

    错误 6

    /home/suhastheju/projects/gcc/gcc-4.8.0/host-i686-pc-linux-gnu/gcc/../.././gcc/gcov.c:416: undefined reference to `gcc_init_libintl()'
    collect2: ld returned 1 exit status
    make[3]: *** [gcov] Error 1
    make[3]: Leaving directory `/home/suhastheju/projects/gcc/gcc-4.8.0/host-i686-pc-linux-gnu/gcc'
    

    解决方案

    添加了-I/usr/include

    【讨论】:

    • 您的回答中描述的错误是由于不满足先决条件造成的,正如我提到的,我已经安装了它。因此,您的回答没有回答我的问题。只需看一下 README,就可以知道需要安装哪些软件包:gcc.gnu.org/install/prerequisites.html
    【解决方案2】:

    在 GCC 源代码的根文件夹中执行 ./contrib/download_prerequisites 脚本。

    【讨论】:

      猜你喜欢
      • 2013-12-12
      • 2016-01-18
      • 1970-01-01
      • 2013-03-18
      • 2013-03-19
      • 1970-01-01
      • 1970-01-01
      • 2013-04-12
      相关资源
      最近更新 更多