我是Python的初学者。当我尝试加载外部DLL(由其他人在Windows中编译)时,如下所示:

from ctypes import *
import cv2, cv as cv

PainterRender = CDLL('/Users/gulilin/Desktop/DLL/PainterRenderDll')


发生错误,如下所示:

Traceback (most recent call last):
  File "/Users/gulilin/Desktop/Project/DLL Test.py", line 7, in <module>
  PainterRender = CDLL('/Users/gulilin/Desktop/DLL/PainterRenderDll')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/gulilin/Desktop/DLL/PainterRenderDll, 6): image not found


谁能告诉我怎么回事?

最佳答案

共享库(例如Windows DLL)类似于已编译的二进制可执行文件:它们仅在编译它们的平台上运行。 ctypes可以也不会在不同平台上的各种二进制格式和调用约定之间转换。您必须将DLL重新编译为Mac OS共享库(我认为是.dylib)。

10-06 14:01