【问题标题】:linux x86_64 vm gcc error in architecture of executable output, exec file format errorlinux x86_64 vm gcc 可执行输出架构中的错误,exec 文件格式错误
【发布时间】:2019-02-12 10:43:21
【问题描述】:

我正在使用 GNU/Linux 64 位 Oracle VM 编译一个简单的 c 程序 main.c:
int main(){ return 0; }
gcc 命令是: gcc -c main.c -o 输出
运行时:./output,报错: “无法执行二进制文件:执行格式错误”

Why the gcc compilation results an executable that doesn't correspond to the architecture of the machine(SYSV and not GNU/Linux)?
提前致谢

【问题讨论】:

    标签: c linux gcc x86-64 file-format


    【解决方案1】:

    -c 标志告诉gcc 生成一个目标文件。目标文件不可执行,而是输入到用于创建可执行文件的链接器中。

    要么放弃-c 标志:

    gcc main.c -o output
    

    或者构建目标文件然后链接它:

    gcc -c main.c
    gcc main.o -o output
    

    有关 GCC 命令行参数的更多信息,请read the documentation 获取您的 GCC 版本。

    【讨论】:

    • 请帮助我的哈希问题先生,只有你可以帮助我@Someprogrammerdude
    • @david12345 如果没有您的作业的完整要求和规范,没有人可以为您提供更多帮助。帮助您满足要求和规范的唯一方法基本上是代替您完成您的任务,没有人真正想做或没有时间做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-18
    • 2017-06-26
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    相关资源
    最近更新 更多