2012-07-16 63 views
18

我实际上正在阅读LFS书籍(版本7.1),并在第53页被封锁。尝试编译gcc,我尝试了以下命令: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 

运行gcc的配置脚本(当然我已经编译了mpfr,mpc和gmp)。 但是,一旦我推出:

make -j4 

我得到以下错误:

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 

我想谷歌它,并试图找到我的解决方案,但毫无效果。有谁知道我为什么会遇到这个错误?

+0

当配置尝试编写一些测试程序发生的情况。 [此链接](http://gcc.gnu.org/wiki/FAQ#configure_suffix)可能会有用。 – ArjunShankar 2012-07-16 10:10:49

+2

*有关更多详细信息,请参阅'config.log'。* - 好建议,这就是它出现在错误消息中的原因。 – DevSolar 2012-07-16 12:26:40

+0

感谢您的链接。但是我尝试了所有的东西,而且我也没有弄清楚问题可能来自哪里。一些论坛说这是一个GCC的错误,它不读取mpc或mpfr的库文件。我会再试一次。无论如何感谢 – 2012-07-19 21:53:26

回答

13

当测试程序试图链接到libmpc/libmpfr/libgmp时,此问题是由dyanmic链接库路径问题导致的。

追加下面的环境变量,让LD链接对正确所以文件:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpc/lib/ 

,然后再次尝试建立海湾合作委员会。

+0

你能举一个这样的路径'/ path/to/mpc/lib /'的例子吗?或者我怎么找到它? – WebQube 2014-08-08 09:59:25

+0

@WebQube你不能执行'sudo find/-iname“libmpc.so”'?这将让你知道路径或运行命令'whereis libmpc.so'或'locate libmpc.so'。 – enthusiasticgeek 2014-10-21 09:13:30

+0

虽然有影响 - 正如我所知,mpc库在* nix系统上并未默认安装,您可能需要手动安装它 - 实际路径取决于您传递给'configure --prefix =/xx/xx' ,默认情况下配置脚本会安装到'/ user/local/lib /' – Fei 2015-11-18 04:59:50

8

“*建筑GCC是不平凡的,但如果你遵循谨慎 很多人冲进试图建立它的指示,而不正确读取安装文档,使这些常见的错误之一以上并不困难。

1)不要的./configure从运行gcc的src目录(这是不支持)=>你需要运行从GCC源目录之外

2)注意配置:如果GCC动态链接的前提条件库( GMP/MPFR/MPC),那么在构建gcc和使用安装的编译器时,共享库必须位于动态链接器的路径(LD_LIBRARY_PATH)中。*“

简单的例子(不存在动态链接到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 

来源: Advogato Doc - 可以从许多不同的原因产生 GNU Doc

+1

没有动态链接的建筑投票,它真的让生活变得轻松。 – TwilightSun 2015-03-16 06:53:32

3

此错误消息。在下面的例子中找出哪一个检查日志文件'/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc/config.log'的最好方法。或者在原始海报案例'/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc'中查找最后一个错误行。

报价GCC FAQ: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:

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.