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

I have a 64-bit RHEL host with 32-bit libraries. One of the providers has a 32-bit .so I would like to download in Python using ctypes.

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

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

Of course, 64-bit libraries are fine. For instance:

CDLL('libc.so.6')

It works great.

+3
source share
1 answer

It seems like the best way to do this is to have a 32-bit python in a separate process, load .so and call the 32-bit python from 64-bit Python.

+1
source

Source: https://habr.com/ru/post/1749425/


All Articles