Mac OS X Python ctypes cdll错误:找不到图像

时间:2013-12-17 13:54:41

标签: python macos ctypes

我是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

谁能告诉我这是怎么回事?

1 个答案:

答案 0 :(得分:1)

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