GCC错误 - 无法执行二进制文件

时间:2012-07-28 00:54:29

标签: gcc

[谢谢大家!对不起我没有看到不匹配的内核,出于某种原因我认为这是我的ubuntu服务器64位]

我使用ct-ng编译了一个自定义gcc工具链,编译成功但我写了一个简单的hello世界,我看到了这个错误

请问有人,请指出我这里有什么问题以及为什么会收到此错误?

错误:

src/main$ ./main 
bash: ./main: cannot execute binary file

关于操作系统

uname -a
Linux lnx-server 3.2.0-25-generic-pae #40-Ubuntu SMP Wed May 23 22:11:24 UTC 2012 i686 i686 i386 GNU/Linux

文件上的一些附加信息

src/main$ file main
main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

文件许可

-rwxrwxr-x 1 balravin balravin  8276 Jul 27 17:45 main
用于编译的

命令

src/main$ x86_64-mvl-linux-gnu-gcc -o main main2.c

GCC配置

> src/main$ x86_64-mvl-linux-gnu-gcc --v Using built-in specs. Target:
> x86_64-mvl-linux-gnu Configured with:
> /home/balravin/tools/platform/x86/src/gnu/gcc/4.2.4/.build/src/gcc-4.2.4/configure
> --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=x86_64-mvl-linux-gnu --prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu
> --with-sysroot=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu/x86_64-mvl-linux-gnu/sysroot
> --enable-languages=c,c++ --disable-sjlj-exceptions --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --enable-threads=posix --enable-target-optspace --with-long-double-128 --disable-nls --disable-multilib --with-local-prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu/x86_64-mvl-linux-gnu/sysroot
> --enable-c99 --enable-long-long Thread model: posix gcc version 4.2.4

终于 main2.c

#include <stdio.h>
int main() {

    printf("\nHello Work\n");
    return 0;
}

2 个答案:

答案 0 :(得分:4)

你的内核是32位的,你已经编译了64位二进制文​​件。您需要在64位硬件上使用64位内核才能运行64位二进制文​​件。

答案 1 :(得分:2)

您正尝试在32位操作系统上运行64位可执行文件。安装64位操作系统,或重建编译器以生成32位可执行文件。