Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb "During startup program exited with code 126."

Tags:

gdb

I am debugging a c++ program:

gdb simplesearch.o

Then gdb startups successfully:

(gdb) Reading symbols from /home/zwx/workspace/xapian/examples/simplesearch.o...done.

But when I tried to run:

(gdb) run

gdb reports:

Starting program: /home/zwx/workspace/xapian/examples/simplesearch.o 
/bin/bash: /home/zwx/workspace/xapian/examples/simplesearch.o: cannot execute binary file
/bin/bash: /home/zwx/workspace/xapian/examples/simplesearch.o: Success
During startup program exited with code 126.

Someone has idea?

like image 461
stackunderflow Avatar asked Apr 16 '12 01:04

stackunderflow


1 Answers

A .o file is not a program, it is an object file that needs to be linked with libraries to produce a program. You can use gdb to inspect code within it, but it is not runnable (the "cannot execute binary file" message). You will need to link it to make a program. Possibly something like

g++ -o simplesearch simplesearch.o

will suffice, but without more information it's not clear if it needs more libraries than just the system C libraries and C++ runtime support, etc.

like image 131
geekosaur Avatar answered Sep 24 '22 08:09

geekosaur