这个页面说关于图书馆搜索的顺序ld.so
:
Unless loading object has RUNPATH: RPATH of the loading object, then the RPATH of its loader (unless it has a RUNPATH), ..., until the end of the chain, which is either the executable or an object loaded by dlopen Unless executable has RUNPATH: RPATH of the executable LD_LIBRARY_PATH RUNPATH of the loading object ld.so.cache default dirs
然后建议:
发布二进制文件时,要么使用 RPATH 而不是 RUNPATH,要么确保在运行之前设置 LD_LIBRARY_PATH。
那么,使用RPATH
withRUNPATH
很糟糕,因为RUNPATH
某种取消RPATH
,所以间接动态加载不能按预期工作?但是为什么后来RPATH
被弃用了RUNPATH
呢?
有人可以解释一下情况吗?