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

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

问题描述

我有一个安装了 32 位库的 64 位 RHEL 主机.一个供应商有一个 32 位.所以我想使用 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.

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天全站免登陆