由于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
但是,在“make”步骤中,这种安装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,但这是不同的主题。)
我的问题是:有人知道我们遇到这些问题的原因/背景吗?有人知道一个合适的解决方案吗? (使用“正确的解决方案”我的意思是一个解决方案,不需要将环境变量或符号链接库设置到不同的目录。对我来说,这些变化很难看,因为它们需要对系统进行更改,而这可能无法追溯到或重做。)
答案 0 :(得分:3)
在GCC源的根文件夹中执行./contrib/download_prerequisites
脚本。
答案 1 :(得分:2)
这些是我在Ubuntu 12.04上使用解决方案编译GCC 4.8.0时遇到的问题。
这可能会对你有帮助。
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.
从中下载软件包 http://ftp.gnu.org
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
Cannot find g++ compiler
我收到此错误是因为我最近安装了操作系统并且没有安装编译器。
sudo apt-get install build-essential
这将安装所有标准构建必备软件
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的路径 和-frfr通过-with-gmp和-with-mpfr标志安装, 但不幸的是,我试图给出路径,但它没有用。
我不能说最后一句话,这是否是一个错误 在构建脚本或其他东西,但波纹管是问题的解决方案。
构建时,在LD_LIBRARY_PATH环境中添加gmp和mpfr安装路径 变量。做如下 export LD_LIBRARY_PATH = / usr / local / lib:$ LD_LIBRARY_PATH
如果您有不同路径的库,请添加库存在的路径
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
/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