我想在cygwin中使用python的(2.6.5)ctypes,但我不知道如何加载dll。
我尝试了各种变体,比如
>>> form ctypes import *
>>> cdll.LoadLibrary("/lib/libcairo.dll.a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Permission denied
答案 0 :(得分:2)
您将无法使用Python ctypes模块加载导入库;它必须是一个真正的DLL。我使用cygwin crypt库和crypt DLL导入库作为示例,在Win7上使用了晚期模型Cygwin。
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> cdll.LoadLibrary('cygcrypt-0.dll')
<CDLL 'cygcrypt-0.dll', handle 380000 at 7ef4564c>
>>>
>>>
>>> cdll.LoadLibrary('libcrypt.dll.a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Permission denied