Linux Gcc编译“无法计算目标文件的后缀:无法编译”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11502045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gcc compilation "cannot compute suffix of object files: cannot compile"
提问by E-Kami
I'm actually reading the LFS book (version 7.1) and I'm blocked at page 53. Trying to compile gcc, I tried the following command:
我实际上正在阅读 LFS 书(7.1 版),但在第 53 页被阻止。尝试编译 gcc,我尝试了以下命令:
./configure --target=$LFS_TGT --prefix=$LFS/build/gcc-build --disable-nls\
--disable-shared --disable-multilib --disable-decimal-float --disable-threads\
--disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath\
--disable-target-libiberty --disable-target-zlib\
--enable-languages=c\
--without-ppl --without-cloog\
--with-mpfr-include=$LFS/source/mpfr/src
--with-mpfr-lib=$LFS/source/mpfr/src/.libs\
--with-gmp-include=/mnt/LFS/source/gmp\
--with-gmp-lib=/mnt/LFS/source/gmp/.libs\
--with-mpc-include=/mnt/LFS/source/mpc/src\
--with-mpc-lib=/mnt/LFS/source/mpc/src/.libs
to run the configure script of gcc (of course I already compiled mpfr, mpc and gmp as well). But once I launch:
运行 gcc 的配置脚本(当然我已经编译了 mpfr、mpc 和 gmp)。但是一旦我启动:
make -j4
I get the following error:
我收到以下错误:
checking for suffix of object files... configure: error: in `/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
I tried to google for it and tried the solutions I found but nothing worked. Does anyone know why I get this error?
我试图用谷歌搜索它并尝试了我找到的解决方案,但没有任何效果。有谁知道我为什么会收到这个错误?
采纳答案by Fei
This issue is caused by dyanmic link library path issue when the test programs try to link against libmpc/libmpfr/libgmp.
此问题是由测试程序尝试链接 libmpc/libmpfr/libgmp 时的动态链接库路径问题引起的。
Append below environment variable to allow ldlink against the correct sofile:
追加下面的环境变量以允许ld链接到正确的so文件:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpc/lib/
Then try build gcc again.
然后再次尝试构建 gcc。
回答by Axel Borja
"*Building GCC is not trivial, but is not difficult if you follow the instructions carefully. Many people rush into trying to build it without reading the installation docs properly and make one or more of these common mistakes:
“*构建 GCC 并非微不足道,但如果您仔细按照说明进行操作,则并不困难。许多人在没有正确阅读安装文档的情况下急于尝试构建它,并犯了以下一个或多个常见错误:
1) do not run ./configure from gcc src dir (this is not supported) => you need to run configure from outside the gcc source directory
1) 不要从 gcc src 目录运行 ./configure (这是不支持的) => 你需要从 gcc 源目录之外运行 configure
2) Note: if GCC links dynamically to the prerequisite libs (GMP/MPFR/MPC) then the shared libraries must be in the dynamic linker's path (LD_LIBRARY_PATH), both when building gcc and when using the installed compiler.*"
2) 注意:如果 GCC 动态链接到必备库 (GMP/MPFR/MPC),那么在构建 gcc 和使用已安装的编译器时,共享库必须位于动态链接器的路径 (LD_LIBRARY_PATH) 中。*
Simple example (without dynamic link to GMP/MPFR/MPC):
简单示例(没有到 GMP/MPFR/MPC 的动态链接):
tar xzf gcc-4.8.0.tar.gz
cd gcc-4.8.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.0/configure --prefix=/opt/gcc-4.8.0
make
make install
Sources: Advogato Doc- GNU Doc
资料来源: Advogato Doc- GNU Doc
回答by Stian Svedenborg
This error message can arise from a number of different reasons. The best way to figure out which one is to check the logfile '/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc/config.log' in the example below. Or in the original posters case '/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc' and look for the last error line.
此错误消息可能由多种不同原因引起。找出哪一个的最佳方法是检查下面示例中的日志文件“/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc/config.log”。或者在原始海报案例 '/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc' 中查找最后一个错误行。
Quoting GCC FAQ: http://gcc.gnu.org/wiki/FAQ#configure_suffix
引用 GCC 常见问题解答:http: //gcc.gnu.org/wiki/FAQ#configure_suffix
Like any of the GNU projects, GCC is using the GNU autotools to commonly configure the compilation for the specifics of the build system. The configure script thereby uses small test programs - usually called conftest.c - to test if certain functions and/or features are available. If the compilation of such a test program fails, you'll see an error message like:
像任何 GNU 项目一样,GCC 使用 GNU 自动工具来为构建系统的细节配置编译。因此,配置脚本使用小型测试程序——通常称为 conftest.c——来测试某些功能和/或特性是否可用。如果此类测试程序的编译失败,您将看到如下错误消息:
checking for suffix of object files... configure: error: in
`/home/manu/gcc/gcc/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/manu/gcc/gcc'
This error message is quite misleading and frequently the problem has nothing to do with the message. You have to check the file 'config.log' in the directory where the error occurred. In the example above, you would have to check the 'config.log' file in the directory '/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc'. There might be several test programs that failed during the configuration, but some of these failures are non-critical. Check for the last error entry in the file.
Common causes for this error message are:
Required libraries for the GCC build are missing, specifically MPFR, GMP and MPC. If installed as shared libraries they must be in the runtime linker's search path so they can be found. Please, follow the instructions in the answer to Why does my ./configure and make fail?
The compiler crashed. For example, if there is an error such as 'conftest.c: internal compiler error:', this indicates a bug in the compiler. If you are using an unmodified version of GCC, please follow the procedure to report the bug.
此错误消息非常具有误导性,并且该问题通常与该消息无关。您必须检查发生错误的目录中的文件“config.log”。在上面的示例中,您必须检查目录“/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc”中的“config.log”文件。可能有几个测试程序在配置过程中失败,但其中一些失败并不严重。检查文件中的最后一个错误条目。
此错误消息的常见原因是:
缺少 GCC 构建所需的库,特别是 MPFR、GMP 和 MPC。如果安装为共享库,它们必须位于运行时链接程序的搜索路径中,以便可以找到它们。请按照为什么我的 ./configure 和 make 失败的答案中的说明进行操作?
编译器崩溃了。例如,如果出现诸如“conftest.c: internal compiler error:”之类的错误,则表明编译器存在错误。如果您使用的是未修改的 GCC 版本,请按照程序报告错误。