如何使用 eclipse 调试 libtool 生成的脚本?
我有一个使用 libtool 构建的大型 C++ 项目。问题是 eclipse 不会运行 libtool 生成的脚本,并且我收到“程序不是可识别的可执行文件”。错误信息。如何使用 Eclipse 调试器?我目前正在使用 kdevelop3 作为编辑器并使用洞察力进行调试..这太可怕了。
我也许可以运行实际的可执行文件,它位于项目目录的 ./libs 中,但随后我必须手动设置 LD_LIBRARY_PATH 之类的东西......必须有更好的方法来做到这一点。
任何帮助将不胜感激!
I have a large c++ project built with libtool. the problem is that eclipse will not run a libtool generated script, and I get a "Program is not a recognized executable." error message. how can I use eclipse debugger? I'm currently using kdevelop3 as an editor and debugging with insight.. which is horrible.
I could perhaps run the actual executable, thats in the ./libs of the project directory, but then I would have to manually set LD_LIBRARY_PATH and stuff like that... there must be a better way to so this.
any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Eclipse 中仍然不支持运行脚本而不是可执行文件,请参阅此错误。在引入该功能之前,您无法在 Eclipse 下调试启用 libtool 的项目,除非您保留类似
单独配置的内容,因此仅依靠静态链接来进行调试。
为此,您
从顶部菜单中打开
Project|Properties
选择
Autotools |从窗口左侧菜单中配置设置
(可选)使用专用
C/C++ Build|Builder设置|构建位置
在
configure|Advanced 下
,用--disable-shared
填写“附加命令行选项”Running a script instead of an executable is still unsupported in Eclipse, see this bug. Until the feature is introduced, you cannot debug a libtool-enabled project under Eclipse unless you keep something like a
separate configuration, thus relying on static linking only for debugging purposes.
To do that, you
Open
Project|Properties
from the top menuSelect
Autotools|Configure Settings
from the left menu of the window(Optionally) Create a new build configuration with a dedicated
C/C++ Build|Builder Settings|Build location
Under
configure|Advanced
, fill the "Additional command-line options" with--disable-shared
您可以通过运行实际的可执行文件而不是 libtool 脚本来解决这个问题。可执行文件通常可以在
.libs/
中找到。因此,在主选项卡上的调试配置中,将C/C++ Application
的值设置为.libs/my_application
之类的值。然后,您只需在调试配置中更新LD_LIBRARY_PATH
即可。转到调试配置的环境选项卡并创建一个名为 LD_LIBRARY_PATH 的新环境变量。您需要将
.libs
目录附加到路径中。因此,该值应如下所示:${project_loc}/.libs:$LD_LIBRARY_PATH
假设您的.libs
文件夹位于项目目录内。You can work around it by running the actual executable instead of the libtool script. The executable will generally be found in
.libs/
. So in your debug configuration on the main tab set the value ofC/C++ Application
to something like.libs/my_application
. Then all you'll need to do us updateLD_LIBRARY_PATH
within your debug configuration.Go to the environment tab of your debug configuration and make a new environment variable called
LD_LIBRARY_PATH
. You'll want to append the.libs
directory to the path. So the value should look like this:${project_loc}/.libs:$LD_LIBRARY_PATH
assuming your.libs
folder is right inside of the project directory.我认为可以编写一个小包装程序来插入“sh libtool --modeexecute”的 exec 来运行 gdb。将其命名为“gdb-libtool”并调用它而不是 gdb。
我在 Windows 和 Linux 下进行开发,所以这是我自己需要的东西。
有一些棘手的地方,比如在 libtool 和 gdb 调用中获取正确的路径.. 去采取行动。
干杯,杰瑞。
I think one could write a little wrapper program to interpose an exec of 'sh libtool --mode execute' to run gdb. Call it 'gdb-libtool' and invoke that instead of gdb.
I am developing under both Windows and Linux so it's something I need for myself.
There are a few tricky bits, like getting the paths right at libtool and gdb invocation.. off to take a swat at that.
Cheers, Jerry.
对于第一点,您可以通过将
-no-install
添加到Makefile.am
中的LDFLAGS
来禁用中间 libtool 脚本,或者您可以只运行make install
并从安装的二进制文件中进行调试。对于第二点,您必须在启动 Eclipse 之前设置并导出您的 LD_LIBRARY_PATH。
For the first point, you can disable intermediate libtool script by adding
-no-install
toLDFLAGS
in yourMakefile.am
OR you can just runmake install
and debug from installed binary.For the second point, you'll have to set and export your
LD_LIBRARY_PATH
before launching eclipse.您需要说服 eclipse 像这样启动 gdb:
请参阅 https:// /www.gnu.org/s/libtool/manual/html_node/Debugging-executables.html
You need to convince eclipse to start gdb like this:
See https://www.gnu.org/s/libtool/manual/html_node/Debugging-executables.html