Reputation: 1814
hello everyone i try to debug a program, which have been installed by makefile. it have a binary file of OpenDPI_demo.o and a shell shellscript OpenDPI_demo. when i gdb OpenDPI_demo.o,i have a problem. i can't run it. the error is:
Starting program: /home/lx/ntop/test/opendpi/src/examples/OpenDPI_demo/OpenDPI_demo.o
/bin/bash: /home/lx/ntop/test/opendpi/src/examples/OpenDPI_demo/OpenDPI_demo.o:can't execute the binary file.
please tell me why. actually i can run the program by ./OpenDPI_demo. thank you.
Upvotes: 0
Views: 1045
Reputation: 436
This is another example of difficulties encountered with programs using libtool.
the file OpenDPI_demo
alongside OpenDPI_demo.o
is actually, as you said, a shell script which wraps the execution of the real compiled file, probably in .libs/OpenDPI_demo
.
libtool needs this wrapper to adjust the runtime library paths and such so that you can execute the program transparently, as if it was actually installed on your system.
The way to correctly debug this application is not
/home/lx/ntop/test/opendpi $ gdb src/examples/OpenDPI_demo/.libs/OpenDPI_demo
but rather using libtool --mode=execute
on the shell script, like the following (it's an example):
/home/lx/ntop/test/opendpi $ ./libtool --mode=execute gdb --args \
src/examples/OpenDPI_demo/OpenDPI_demo -f capture.pcap
Upvotes: 0
Reputation: 393789
Suggest you use
gdb OpenDPI_demo
instead
In your makefile if it depens on the object, make it depend on OpenDPI_demo, e.g.
Upvotes: 0
Reputation: 182734
Based on the extension, the file is an object file. It is used by the linker (alongside other object files) to produce an executable. It's the real executable the one you want to run/debug.
Upvotes: 2