交叉编译GCC:在检查动态链接器特性时,GCC_NO_EXECUTABLES后不允许链接测试

时间:2017-09-29 11:06:06

标签: c++ c gcc compiler-errors

我正在尝试通过关注this来为LFS编译gcc-4.8.3

使用make时,出现以下错误:

checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make[1]: *** [configure-target-libstdc++-v3] Error 1
make[1]: Leaving directory `/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build'
make: *** [all] Error 2

配置选项:

../configure                                       \
    --target=$LFS_TGT                              \
    --prefix=/tools                                \
    --with-glibc-version=2.11                      \
    --with-sysroot=$LFS                            \
    --with-newlib                                  \
    --without-headers                              \
    --with-local-prefix=/tools                     \
    --with-native-system-header-dir=/tools/include \
    --disable-nls                                  \
    --disable-shared                               \
    --disable-multilib                             \
    --disable-decimal-float                        \
    --disable-threads                              \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libmpx                               \
    --disable-libquadmath                          \
    --disable-libssp                               \
    --disable-libvtv                               \
    --disable-libstdcxx                            \
    --enable-languages=c,c++

其中$LFS_TGTx86_64-lfs-linux-gnu

PasteBin上的

config.log

最后几行输出:

checking if /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    supports -fno-rtti -fno-exceptions... no
checking for /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    option to produce PIC... -fPIC -DPIC
checking if /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    PIC flag -fPIC -DPIC works... yes
checking if /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    static flag -static works... no
checking if /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    supports -c -o file.o... yes
checking if /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    supports -c -o file.o... (cached) yes
checking whether the /mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/xgcc -B/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/ -B/tools/x86_64-lfs-linux-gnu/bin/ -B/tools/x86_64-lfs-linux-gnu/lib/ -isystem /tools/x86_64-lfs-linux-gnu/include -isystem /tools/x86_64-lfs-linux-gnu/sys-include    linker (/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build/./gcc/collect-ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
make[1]: *** [configure-target-libstdc++-v3] Error 1
make[1]: Leaving directory `/mnt/c/Users/admin/Desktop/Projects/AssaultArchitecture/sources/gcc-4.8.3/build'
make: *** [all] Error 2

4 个答案:

答案 0 :(得分:2)

如果您在x86_64计算机上构建此计算机并且x86_64为目标,则您实际上并未构建交叉编译器。
您似乎正在构建隔离的stage1编译器,因此您必须添加--disable-bootstrap标志。如果您的构建目标平台不是本机平台(交叉编译器),则默认情况下GCC会禁用引导程序。

答案 1 :(得分:1)

如果要构建LFS,则应检查正在使用的用户,并确保它不是root用户。

答案 2 :(得分:0)

这里涉及完全相同的问题:

https://gcc.gnu.org/ml/gcc-help/2012-07/msg00018.html

建议可能缺少相应的glibc(定位x86_64-lfs-linux-gnu),并且需要安装。

HTH。

答案 3 :(得分:0)

您需要检查 config.log 以找出 configure 尝试运行的命令;例如:

configure:9604: checking whether the x86_64-lfs-linux-gnu-gcc linker (/usr/x86_64-lfs-linux-gnu/bin/ld -m elf_x86_64
) supports shared libraries
configure:10684: result: no
configure:10929: checking dynamic linker characteristics
configure:11375: error: Link tests are not allowed after GCC_NO_EXECUTABLES.

在这种情况下,请手动运行 /usr/x86_64-lfs-linux-gnu/bin/ld -m elf_x86_64。它可能会产生类似的结果:

/usr/x86_64-lfs-linux-gnu/bin/ld: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

因此,在这种情况下,您会知道找不到 libz.so.1