Python ctypes 可以在 x86-64 上加载 32 位 C 库吗?
我有一台安装了 32 位库的 64 位 RHEL 主机。一个供应商有 32 位。所以我想使用 ctypes 加载到 Python 中。
from ctypes import CDLL
CDLL('32bitdinosaur.so')
OSError: 32bitdinosaur.so: wrong ELF class: ELFCLASS32
当然64位库是可以的。例如:
CDLL('libc.so.6')
工作正常。
I have a 64 bit RHEL host with 32 bit libraries installed. One vendor has a 32 bit .so I'd like to load into Python using ctypes.
from ctypes import CDLL
CDLL('32bitdinosaur.so')
OSError: 32bitdinosaur.so: wrong ELF class: ELFCLASS32
Of course 64 bit libraries are OK. Eg:
CDLL('libc.so.6')
Works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来最好的方法是在单独的进程中让 32 位 python 加载 .so,然后从 64 位 Python 调用 32 位 python。
It looks like the best way to do this is to have a 32 bit python in a separate process load the .so, and call the 32 bit python from a 64 bit Python.