我在基于Heroku的环境中运行,因此不允许在系统空间中安装软件包。要解决此问题,请将其安装到/app/.apt
并更新LD_LIBRARY_PATH
以反映此情况。
我正在尝试使用cyrus-sasl2,所以安装它并看到它已安装,但是当我尝试使用这个库时,我发现它无法获取gssapiv2,它也安装在同一个位置。
使用LD_DEBUG=all
运行代码我看到了一些有趣的内容
file=/usr/lib/x86_64-linux-gnu/sasl2/libsasldb.so [0]; dynamically loaded by /app/.apt/usr/lib/x86_64-linux-gnu/libsasl2.so.2 [0]
通常情况下,我看到图书馆会进行搜索,但这总是会占用系统并且不会执行搜索。我期待以下内容
1673:
1673: file=libsasl2.so.2 [0]; needed by /app/.heroku/python/lib/python2.7/site-packages/sasl/saslwrapper.so [0]
1673: find library=libsasl2.so.2 [0]; searching
1673: search path=/app/.heroku/vendor/lib:/app/.heroku/python/lib:/app/.apt/usr/lib/x86_64-linux-gnu:/app/.apt/usr/lib:tls/x86_64:tls:x86_64: (LD_LIBRARY_PATH)
1673: trying file=/app/.heroku/vendor/lib/libsasl2.so.2
1673: trying file=/app/.heroku/python/lib/libsasl2.so.2
1673: trying file=/app/.apt/usr/lib/x86_64-linux-gnu/libsasl2.so.2
但在libsasldb.so
的情况下我没有看到。
我的问题是,为什么链接器不会搜索,而是总是使用系统版本?
答案 0 :(得分:0)
在上面的例子中,结果是cyrus-sasl使用编译时标志来定义插件目录并将从该路径加载。我重新编译了项目,将插件目录更改为heroku位置,并查看以下系统调用
openat(AT_FDCWD, "/app/.apt/usr/lib/sasl2", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
open("/app/.apt/usr/lib/sasl2/libcrammd5.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libcrammd5.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libdigestmd5.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libdigestmd5.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libscram.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libscram.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/liblogin.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/liblogin.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libcrammd5.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libldapdb.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libanonymous.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libanonymous.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libplain.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libplain.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libntlm.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libntlm.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libntlm.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libotp.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libldapdb.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libldapdb.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libanonymous.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/liblogin.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libscram.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libotp.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libotp.so.2", O_RDONLY|O_CLOEXEC) = 6
open("/app/.apt/usr/lib/sasl2/libdigestmd5.la", O_RDONLY) = 6
open("/app/.apt/usr/lib/sasl2/libplain.la", O_RDONLY) = 6
简而言之,它控制链接本身,这就是链接器从不搜索其他库的原因。