加载库失败,但符号可从引用的库中获得
我正在尝试为我们拥有的供应商提供的 C++ 库编写 Python 绑定。我正在继续前进,但这非常痛苦(部分原因是我们没有图书馆的来源)。
现在,gcc(4.4.4)抱怨它找不到一些异常类:
Load library for "FOO_Sessions" failed, the system error message is "/home/djc/foo/lib/libFOO_Sessions.so: undefined symbol: _ZTIN3foo4some22SomeExceptionE"
但是,我在 libFOO_Elsewhere 中找到了 _ZTIN3foo4some22SomeExceptionE (使用 objdump -x),可以在同一个 /home/djc/foo/lib 中找到/ dir 并且已经在编译器调用时使用 -l 开关进行了引用。
LD_DEBUG=all 报告以下内容(感谢 Erik 的建议):
/home/djc/foo/lib/libFOO_Sessions.so: error: symbol lookup error: undefined symbol: _ZTIN3foo4some22SomeExceptionE (fatal)
但是, objdump -p 为 libFOO_Sessions.so 报告了这一点:
Dynamic Section:
NEEDED libFOO_Connections.so
NEEDED libFOO_Session_Base.so
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libc.so.6
SONAME libFOO_Sessions.so
libFOO_Elsewhere (包含 _ZTIN3foo4some22SomeExceptionE)不应该也在 libFOO_Sessions 的 NEEDED 条目中吗?
I'm trying to write a Python binding for a C++ library from a vendor we have. I'm moving along, but it's quite painful (partly because we don't have the source for the library).
Right now, gcc (4.4.4) complains about some Exception class it can't find:
Load library for "FOO_Sessions" failed, the system error message is "/home/djc/foo/lib/libFOO_Sessions.so: undefined symbol: _ZTIN3foo4some22SomeExceptionE"
However, I have found _ZTIN3foo4some22SomeExceptionE in libFOO_Elsewhere (using objdump -x), which can be found in the same /home/djc/foo/lib/ dir and is already referenced using the -l switch on the compiler invocation.
LD_DEBUG=all reports the following (thanks Erik for the suggestion):
/home/djc/foo/lib/libFOO_Sessions.so: error: symbol lookup error: undefined symbol: _ZTIN3foo4some22SomeExceptionE (fatal)
However, objdump -p reports this for libFOO_Sessions.so:
Dynamic Section:
NEEDED libFOO_Connections.so
NEEDED libFOO_Session_Base.so
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libc.so.6
SONAME libFOO_Sessions.so
Shouldn't libFOO_Elsewhere (which contains _ZTIN3foo4some22SomeExceptionE) be in a NEEDED entry for libFOO_Sessions, as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行前将LD_LIBRARY_PATH设置为/home/djc/foo/lib/,或者在libFOO_Sessions.so之前显式加载依赖库。
man ld-linux
解释动态链接器将如何搜索。编辑:
另外,在运行之前设置 LD_DEBUG=all ,以便查看动态链接器如何搜索。
Set LD_LIBRARY_PATH to /home/djc/foo/lib/ before running, or explicitly load the dependant library before libFOO_Sessions.so.
man ld-linux
explains how the dynamic linker will search.EDIT:
Also, set
LD_DEBUG=all
before running in order to see how the dynamic linker searches.