GDB “cannot open shared object file” Issue

≯℡__Kan透↙ 提交于 2019-12-20 07:21:54

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/23400322/gdb-cannot-open-shared-object-file-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!