【问题标题】:Can Python ctypes load a 32bit C library on x86-64?Python ctypes 可以在 x86-64 上加载 32 位 C 库吗?
【发布时间】:2011-03-02 06:04:15
【问题描述】:

我有一个安装了 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')

工作正常。

【问题讨论】:

  • 您可能需要运行 32 位 Python 解释器。

标签: python 32bit-64bit ctypes


【解决方案1】:

看起来最好的方法是让 32 位 python 在单独的进程中加载​​ .so,并从 64 位 Python 调用 32 位 python。

【讨论】:

  • 如何在 debian linux 上同时运行 32 位和 64 位 python?
猜你喜欢
  • 2011-05-23
  • 1970-01-01
  • 2010-09-18
  • 1970-01-01
  • 1970-01-01
  • 2011-07-06
  • 2013-04-02
  • 2012-08-06
  • 2016-02-13
相关资源
最近更新 更多