gdb 和 makefile
大家好 我尝试调试一个已通过 makefile 安装的程序。 它有一个二进制文件 OpenDPI_demo.o 和一个 shell shellscript OpenDPI_demo。 当我 gdb OpenDPI_demo.o 时,我遇到了问题。我无法运行它。错误是:
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.
请告诉我原因。实际上我可以通过./OpenDPI_demo运行该程序。 谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据扩展名,该文件是目标文件。链接器(与其他目标文件一起)使用它来生成可执行文件。这是您想要运行/调试的真正的可执行文件。
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.
这是使用 libtool 的程序遇到困难的另一个例子。
正如您所说,文件
OpenDPI_demo
与OpenDPI_demo.o
实际上是一个 shell 脚本,它包装了实际编译文件的执行,可能在.libs/OpenDPI_demo 中
。libtool 需要这个包装器来调整运行时库路径等,以便您可以透明地执行程序,就像它实际安装在您的系统上一样。
正确调试此应用程序的方法不是
在 shell 脚本上使用 libtool --mode=execute ,如下所示(这是一个示例):
This is another example of difficulties encountered with programs using libtool.
the file
OpenDPI_demo
alongsideOpenDPI_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
but rather using
libtool --mode=execute
on the shell script, like the following (it's an example):建议您在 makefile 中使用
,
如果它依赖于对象,请使其依赖于 OpenDPI_demo,例如
Suggest you use
instead
In your makefile if it depens on the object, make it depend on OpenDPI_demo, e.g.