LoadLibraryExA - Die angegebene Datei wurde nicht gefunden
-
Ich habe ein Python Modul in C geschrieben und mit MinGW und den Distutils von Python übersetzt. Jetzt möchte ich es gerne importieren und bekomme folgendes:
>>> import tpytk.win32_wrap # trying C:\PYTHON24\lib\site-packages\tpytk\win32_wrap.pyd Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: DLL load failed: Die angegebene Datei wurde nicht gefunden. >>>Ich hab Python mit dem Programm Dependency Walker gestartet und bekomme folgendes:
GetProcAddress(0xBFF60000 [KERNEL32.DLL], "InterlockedCompareExchange") called from "PYTHON24.DLL" at address 0x1E0A4FB4 and returned 0x83E6CC98. LoadLibraryExA("C:\PYTHON24\lib\site-packages\tpytk\win32_wrap.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "PYTHON24.DLL" at address 0x1E054705. LoadLibraryExA("C:\PYTHON24\lib\site-packages\tpytk\win32_wrap.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: Die angegebene Datei wurde nicht gefunden (2).Das Problem ist, dass die Datei C:\PYTHON24\lib\site-packages\tpytk\win32_wrap.pyd existiert. Welche ursache kann also diese Fehlermeldung haben? .pyd sind .DLL Dateien, nur Python benennt sie als .pyd. Das ist sonst auch kein problem. Ich hab auch schon versucht die Datei in .DLL umzubennenen, mit dem selben Resultat.
Hier noch das Python modul:
#include <Python.h> #include "structmember.h" static PyMethodDef win32_wrap_module_methods[] = { {NULL, NULL, 0, NULL} }; PyMODINIT_FUNC initwin32_wrap(void) { PyObject *m, *d; PyObject *tmp; m = Py_InitModule( "win32_wrap", win32_wrap_module_methods ); d = PyModule_GetDict( m ); }
-
Problem gelöst. Anscheinent arbeiten die Distutils nicht richtig. Ich hab die DLL jetzt mit dem MinGW dllwrap tool erstellt.
dllwrap --dllname foo.pyd --driver-name gcc --def win32_wrap.def -o win32_wrap.pyd win32_wrap.o -s --entry _DllMain@12 --target=i386-mingw32 -LC:\Python24\Libs -lpython24Es hatte also nichts mit der WinAPI zu tun, außer der irreführenden Fehlermeldung.