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

This issue is caused by dyanmic 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.


"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:

  1. do not run ./configure from gcc src dir (this is not supported) => you need to run configure from outside the gcc source directory

  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."

Simple example (without dynamic link to 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