Python ctypes 可以在 x86-64 上加载 32 位 C 库吗?

发布于 2024-09-04 17:54:49 字数 310 浏览 1 评论 0原文

我有一台安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-09-11 17:54:49

看起来最好的方法是在单独的进程中让 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文