Gcc compilation “cannot compute suffix of object files: cannot compile”

后端 未结 3 1179
一整个雨季
一整个雨季 2021-01-31 18:02

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         


        
相关标签:
3条回答
  • 2021-01-31 18:16

    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.

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

    0 讨论(0)
  • 2021-01-31 18:17

    "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

    0 讨论(0)
  • 2021-01-31 18:35

    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.

    0 讨论(0)
提交回复
热议问题