Python ctypes可以在x86-64上加载32位C库吗? [英] Can Python ctypes load a 32bit C library on x86-64?

查看:428
本文介绍了Python ctypes可以在x86-64上加载32位C库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了32位库的64位RHEL主机。一个供应商提供32位.so,我想使用ctypes加载到Python中。

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

当然64位库也可以。例如:

Of course 64 bit libraries are OK. Eg:

CDLL('libc.so.6')

工作正常。

推荐答案

这似乎是最好的方法这样做是为了让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.

这篇关于Python ctypes可以在x86-64上加载32位C库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆