Compilation gcc 4.6.2 (cannot compute suffix of object files)

前端 未结 2 952
春和景丽
春和景丽 2021-02-19 07:51

Problem when compiling gcc 4.6.2:

checking for avr-gcc... /data/data6/soft/src_build/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -B/data/data6/soft/src_buil         


        
相关标签:
2条回答
  • 2021-02-19 07:58

    "*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-02-19 08:06

    I had the same problem cross-compiling for mips.

    Step one: Cross-compile the binutils for your target. Install them somewhere sane. I use /usr/local/[target]-gcc

    Make sure you configure them with --program-prefix=[target]-

    Something like (untested):

    configure --prefix=/usr/local/avr-gcc --program-prefix=avr- --target=avr
    

    Then you need to set up some environment variables so GCC can find them:

    export AR_FOR_TARGET=/usr/local/avr-gcc/bin/avr-ar
    export LD_FOR_TARGET=/usr/local/avr-gcc/bin/avr-ld
    export OBJDUMP_FOR_TARGET=/usr/local/avr-gcc/bin/avr-objdump
    export NM_FOR_TARGET=/usr/local/avr-gcc/bin/avr-nm
    export RANLIB_FOR_TARGET=/usr/local/avr-gcc/bin/avr-ranlib
    export READELF_FOR_TARGET=/usr/local/avr-gcc/bin/avr-readelf
    export STRIP_FOR_TARGET=/usr/local/avr-gcc/bin/avr-strip
    export AS_FOR_TARGET=/usr/local/avr-gcc/bin/avr-as
    

    Now you can configure and compile GCC. Ensure you start from a completely empty build directory, otherwise gcc/as etc won't get recreated.

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