yambo
yambo

Reputation: 1807

GDB error - not in executable format: file format not recognized

I'm trying to use gdb with a simple hello world program, but having some trouble

hello.c

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

I then compile using the following two commands:

gcc -o hello.o hello.c

gcc -g -o hello.o hello.c

But when I type gdb hello.c I get an error: "/home/myName/hello.c": not in executable format: file format not recognized

Does anybody know why this may be?

Upvotes: 0

Views: 1376

Answers (1)

kaylum
kaylum

Reputation: 14046

You need to run and debug the executable not the source file. And executables by common convention should not have .o as those are for intermediate objects. So try: gcc -g -o hello hello.c && gdb ./hello

Upvotes: 1

Related Questions