GDB“无法打开共享对象文件”问题 [英] GDB "cannot open shared object file" Issue
问题描述
我已阅读 gdb表示无法打开共享对象文件 和 gdb无法打开共享对象文件并遵循
我有一个链接到共享库文件的二进制文件( /zzz/yyy/xxx.so
)。在将 LD_LIBRARY_PATH
设置为 / zzz / yyy /
并运行没有GDB的二进制文件后,它执行得非常好。
然而,当我试图使用GDB调试这个二进制文件时,GDB说:
<加载共享库时出错:xxx.so:无法打开共享目标文件:没有这样的文件或目录
我已经拥有(设置为.gdbinit):
(gdb)show env LD_LIBRARY_PATH
LD_LIBRARY_PATH =/ zzz / yyy /
和
(gdb)show solib-search-path
加载非绝对共享库符号文件的搜索路径是/ zzz / yyy /。
在我的系统中:
%printenv LD_LIBRARY_PATH
/ zzz / yyy
什么是其他可能的原因为什么GDB仍然无法找到这个共享库?
然而,当我试图使用GDB来调试这个二进制文件,GDB说:加载共享库时出错:xxx.so:无法打开共享对象文件:没有这样的文件或目录
你错了:这不是说GDB,它是动态加载器。 GDB本身并不在乎 LD_LIBRARY_PATH
设置为什么,它只是运行你的程序。但是你的程序无法运行。
最常见的原因是:你正在重新设置你的 LD_LIBRARY_PATH
code>〜/ .cshrc ,GDB在一个单独的shell中运行你的程序,并且该shell读取你的 .cshrc
,所以你的程序以不正确的环境执行。
修正是为 LD_LIBRARY_PATH
用于非交互式shell。见例如这个回答。
I've already read gdb says "cannot open shared object file" and gdb can not open shared object file and followed the instructions.
I have a binary which is linked to a shared library file (/zzz/yyy/xxx.so
). After I set LD_LIBRARY_PATH
to /zzz/yyy/
and run the binary without GDB, it executes very well.
However, when I was trying to use GDB to debug this binary, GDB says:
error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory
I already have (set in .gdbinit):
(gdb)show env LD_LIBRARY_PATH
LD_LIBRARY_PATH = "/zzz/yyy/"
and
(gdb) show solib-search-path
The search path for loading non-absolute shared library symbol files is "/zzz/yyy/".
and in my system:
% printenv LD_LIBRARY_PATH
/zzz/yyy
What's the other possible reasons why GDB still can't find this shared library?
However, when I was trying to use GDB to debug this binary, GDB says: error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory
You are mistaken: it's not GDB that says that, it's the dynamic loader. GDB itself doesn't care what LD_LIBRARY_PATH
is set to, it simply runs your program. But your program can not run.
The most common cause: you are re-setting your LD_LIBRARY_PATH
in your ~/.cshrc
, and GDB runs your program in a separate shell, and that shell reads your .cshrc
, so your program executes with incorrect environment.
The fix is to make .cshrc
not set LD_LIBRARY_PATH
for non-interactive shells. See e.g. this answer.
这篇关于GDB“无法打开共享对象文件”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!