Python calls DLL and reports an error windowserror: [error 126]

The calling code
Note: C++ files (CPP) : (Add extern “C” modifiers to function declarations) otherwise the method name will not be recognized by Python
Load it depending on what convention the function you’re going to call conforms to. Windll and CDLL are objects of the windll and CDLL classes, respectively
Stdcall calling convention:
Objdll = ctypes. Windll. LoadLibrary (” dllpath “)
Objdll = ctypes. Windll (” dllpath “)
Cdecl calling convention:
Objdll = ctypes.cdl. LoadLibrary(“dllpath”)
Objdll = ctypes.cdll (“dllpath”)
After the call, you can use the functions in the DLL
print Objdll.Add(1, 102)

Objdll = ctypes.cdl.loadlibrary (“D:\\ DLL \\ \PosterDetector. DLL “)
An error

USES python to call C++ DLL to report an error

Traceback (most recent call last):
File “E:/work/proc/video_web/”, line 157, in < module>
Objdll = ctypes.cdl.loadlibrary (os.path.join(APP_ROOT,” DLL “,”PosterDetector. DLL “)
File “d:\python27\Lib\ctypes\ init__. Py “, line 444, In LoadLibrary
return self._dlltype(name)
File “d:\ Lib\ctypes\ ___, init__ “, line 366, in ___
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126]
To solve
The reason is that PosterDetector also relies on other DLLS,
Simply putting the two DLL files in the same directory doesn’t work, because the Python process didn’t start on the same directory as PosterDetector.

put the other DLLS and the current PosterDetector. DLL in the same folder and add the code:
os.chdir(D:\\ DLL “))

Read More: