[英]GDB “cannot open shared object file” Issue
I've already read gdb says "cannot open shared object file" and gdb can not open shared object file and followed the instructions. 我已经读过gdb说“无法打开共享对象文件”,并且gdb无法打开共享对象文件,并按照说明进行操作。
I have a binary which is linked to a shared library file ( /zzz/yyy/xxx.so
). 我有一个链接到共享库文件(
/zzz/yyy/xxx.so
)的二进制文件。 After I set LD_LIBRARY_PATH
to /zzz/yyy/
and run the binary without GDB, it executes very well. 在将
LD_LIBRARY_PATH
设置为/zzz/yyy/
并运行不带GDB的二进制文件后,它执行得很好。
However, when I was trying to use GDB to debug this binary, GDB says: 但是,当我尝试使用GDB调试此二进制文件时,GDB说:
error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory
I already have (set in .gdbinit): 我已经有(在.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? GDB仍然找不到此共享库的其他可能原因是什么?
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
但是,当我尝试使用GDB调试此二进制文件时,GDB表示:加载共享库时出错:xxx.so:无法打开共享库文件:没有这样的文件或目录
You are mistaken: it's not GDB that says that, it's the dynamic loader. 您误会了:不是GDB这么说,而是动态加载程序。 GDB itself doesn't care what
LD_LIBRARY_PATH
is set to, it simply runs your program. GDB本身并不关心
LD_LIBRARY_PATH
设置为什么,它只是运行您的程序。 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. 最常见的原因:您正在
~/.cshrc
中重新设置LD_LIBRARY_PATH
,并且GDB在单独的shell中运行程序,并且该shell读取了.cshrc
,因此您的程序在错误的环境下执行。
The fix is to make .cshrc
not set LD_LIBRARY_PATH
for non-interactive shells. 解决方法是使
.cshrc
不在非交互式shell中设置LD_LIBRARY_PATH
。 See eg this answer. 参见例如这个答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.