gdb说“无法打开共享对象文件”

编程入门 行业动态 更新时间:2024-10-04 05:31:15
本文介绍了gdb说“无法打开共享对象文件”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个二进制和一个共享库。 共享库编译时使用:

all: g ++ -g -shared -fpic $(SOURCES)-o libmisc.so

二进制文件编译时使用:

LIBS = -L ../../ misc / src

LDFLAGS = -lmisc

all: g ++ -g -o mainx $(INCLUDE)$ )$(LIBS)$(LDFLAGS)

我设置在〜/ .bashrc export LD_LIBRARY_PATH = / mnt / sda5 / Programming / misc / src / 到libmisc.so输出路径。

从控制台调试工作正常:

gdb mainx

但是从Emacs22启动gdb失败,并显示以下消息:

启动程序:/ mnt / sda5 /编译/ main / src / mainx / mnt / sda5 / Programming / main / src / mainx:加载共享库时出错:libmisc.so:无法打开共享对象文件:没有这样的文件或目录

这看起来很棘手,我不能解决它。我不知道这是一个emacs的问题,或者我应该在gdb的命令行中传递一个参数。请与我分享您的想法。

vmihai

解决方案

Emacs在它调用gdb之前不读取.bashrc。尝试在您的.gdbinit文件中设置set solib-search-path和set solib-absolute-path

I have one binary and one shared library. The shared library is compiled with:

all: g++ -g -shared -fpic $(SOURCES) -o libmisc.so

the binary is compiled with:

LIBS=-L../../misc/src

LDFLAGS=-lmisc

all: g++ -g -o mainx $(INCLUDE) $(SOURCE) $(LIBS) $(LDFLAGS)

I set in ~/.bashrc export LD_LIBRARY_PATH=/mnt/sda5/Programming/misc/src/ to the libmisc.so output path.

Debugging from console works fine:

gdb mainx

However from Emacs22, launching gdb fails with the following message:

"Starting program: /mnt/sda5/Programming/main/src/mainx /mnt/sda5/Programming/main/src/mainx: error while loading shared libraries: libmisc.so: cannot open shared object file: No such file or directory"

This looks very tricky for the moment, and I couldn't solve it. I am not sure if this a emacs's problem, or I should pass a parameter in gdb's command line. Please share your ideas with me.

vmihai

解决方案

Emacs probably does not read your .bashrc before it invokes gdb. Try to put 'set solib-search-path' and 'set solib-absolute-path in your .gdbinit file instead

更多推荐

gdb说“无法打开共享对象文件”

本文发布于:2023-11-02 06:42:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551649.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法打开   对象   文件   gdb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!