GNU C交叉编译器:无法执行二进制文件

时间:2014-04-23 11:38:25

标签: linux unix gcc busybox

我一直在尝试从源代码编译busybox for ttylinux x64我目前正在处理。由于某些bug(与描述here非常相似),我被迫使用交叉编译器。

但这件事拒绝合作。当我尝试运行它时:

$ /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc --version

我明白了:

-bash: /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc: cannot execute binary file

这是不同的诊断输出:

$ ldd /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc
not a dynamic executable

$ uname -mpi
x86_64 unknown unknown

$ uname -a
Linux ttylinux_host 3.7.1 #1 SMP Mon May 27 14:31:18 MST 2013 x86_64 GNU/Linux

$ objdump -f /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc
/mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc: file format elf32-i386
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x08048188

任何人都可以帮我解决这个问题吗?我相信x64应该没有运行i386代码的问题?

BTW:交叉编译器源自here

3 个答案:

答案 0 :(得分:0)

交叉编译器的起源是什么?跨本机编译器因依赖于工具链的构建主机的体系结构而臭名昭着。在将工具链移动到不同的架构之前,这些都不会引起注意。 您可以将工具链中任何可执行文件的运行时二进制文件移动到具有“文件”实用程序的某个主机。尽管来自 ldd 的消息已经暗示二进制文件在当前(或任何?)架构上运行是不可接受的,但这可能会告诉你很多。针对工具链中的二进制文件运行的实用程序 nm 可能很有用。如果他们都抱怨文件是不可执行的,那么我认为你需要重新获得一个工作工具链。

答案 1 :(得分:0)

我认为这就是答案:

 Try this:
 readelf --headers /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc

 look for a line in the output that is something like:
 [Requesting program interpreter: /lib/ld-blahblah]

 Do you have the /lib/ld-blahblah file (for whatever blahblah really is) in the runtime environment? Most probably not. Make a symlink from what you see in the output above to what is actually on the machine.

为了帮助澄清您的问题,您应该更清楚地说明:

 Are you saying that ttylinux-x86_64 has gcc but it doesn't work? Or that ttylinux does not have gcc and you are NFS-mounting one?

并提示得到比此处更好的帮助:

 Wouldn't it help if you asked the ttylinux maintainer?

答案 2 :(得分:0)

这看起来像是为纯64位用户空间配置的内核,没有i386支持。

在内核配置中这将是CONFIG_IA32_EMULATION。检查/proc/config.gz以确认。