Can Python ctypes load a 32bit C library on x86-64?

拈花ヽ惹草 提交于 2019-12-10 17:53:30

问题


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.


回答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.



来源:https://stackoverflow.com/questions/3015970/can-python-ctypes-load-a-32bit-c-library-on-x86-64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!