【问题标题】:GDB error - not in executable format: file format not recognizedGDB 错误 - 不是可执行格式:文件格式无法识别
【发布时间】:2021-09-21 00:13:29
【问题描述】:

我正在尝试将 gdb 与一个简单的 hello world 程序一起使用,但遇到了一些问题

hello.c

#include <stdio.h>
int main()
{
   printf("Hello World");
   return 0;
}

然后我使用以下两个命令进行编译:

gcc -o hello.o hello.c

gcc -g -o hello.o hello.c

但是当我输入 gdb hello.c 时,我得到一个错误: "/home/myName/hello.c": not in executable format: file format not recognized

有人知道为什么会这样吗?

【问题讨论】:

    标签: c linux gdb


    【解决方案1】:

    您需要运行和调试可执行文件而不是源文件。按照惯例,可执行文件不应该有 .o ,因为它们是用于中间对象的。所以试试:gcc -g -o hello hello.c &amp;&amp; gdb ./hello

    【讨论】:

      猜你喜欢
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-13
      相关资源
      最近更新 更多