mercredi 5 août 2015

Loading .dll with ctypes


I have a .dll with dependencies to some other (Sundials ODE solver) .dlls. I use windows 8.1 with mingw to compile and link the c-code I use for my .dll. When trying to load them with Python and ctypes I get a pop-up with a System error: cannot find libsundials_cvode.dll since it does not exist on the computer and when you close the popup Python spits out WindowsError: [Error 126] Cannot find the module Cannot understand why this is, because gcc compiles and links the files fine without errors (and yes, they do exist)... I have even tried to copy the dependent dlls into the directory where my python script is, without success.

I run the following compile and linker commands without any warnings or errors

gcc -c -I c:\sundials\include cfile.c
gcc -shared -o clib.dll cfile.o -L. C:\sundials\instdir\lib\libsundials_cvode.dll -L. C:\sundials\instdir\lib\libsundials_nserial.dll

My python test script giving the abovementioned error is

import ctypes
lib = ctypes.cdll.LoadLibrary('clib.dll')

I'm a beginner with gcc and c, but quite experienced with Python. Any suggestions what might be the reason?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire