Using python.ctypes with cygwin

I want to use python (2.6.5) ctypes with cygwin, but I don't know how to load the dll.

I tried various options like

>>> 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
+3
source share
1 answer

You cannot load the import library using the Python ctypes module; it must be a real dll. I used both the crypt cygwin library and the crypt DLL import library as examples with the latest Cygwin model on Win7.


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
+2
source

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


All Articles