dlopen() search path

余生颓废 提交于 2019-12-04 22:10:30

问题


is there a way to find out programmatically which paths are searched by dlopen() for shared objects? I always thought dlopen() would only look in /lib and /usr/lib but now I've seen that on Linux Mint several core components like libglib-2.0.so are in a wholly different folders, namely in /rofs/lib/i386-gnu-linux and some others. Is there a way to get to know all these paths that dlopen() will search through for a shared object? I already checked the environment variable LD_LIBRARY_PATH but it's not defined at all.


回答1:


look at the ldconfig man page, and the file: /etc/ld.so.conf




回答2:


In addition of the ld.so.conf hint:

If you want to ensure that a specific library is dlopen-ed, pass a path to dlopen, e.g. dlopen("/some/path/to/lib.so", RTLD_LOCAL) or maybe dlopen("./lib.so", RTLD_LOCAL) but not dlopen("lib.so", RTLD_LOCAL)



来源:https://stackoverflow.com/questions/8193640/dlopen-search-path

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