linuxgcclinux-from-scratch

Gcc compilation "cannot compute suffix of object files: cannot compile"


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:

./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:

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?


Solution

  • This issue is caused by dynamic link library path issue when the test programs try to link against libmpc/libmpfr/libgmp.

    Append below environment variable to allow ld link against the correct so file:

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

    Then try build gcc again.