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

时间:2021-07-29 12:57:08

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.

我有一个64位RHEL主机,安装了32位库。一个供应商有一个32位。所以我想使用ctypes加载到Python。

from ctypes import CDLL
CDLL('32bitdinosaur.so')                        

OSError: 32bitdinosaur.so: wrong ELF class: ELFCLASS32

Of course 64 bit libraries are OK. Eg:

当然64位库是可以的。例如:

CDLL('libc.so.6')

Works fine.

工作正常。

1 个解决方案

#1


1  

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.

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

#1


1  

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.

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