DLL calling Python C/API has dependency issues

2019-07-25 07:27发布

问题:

This question is a partial resolution to the question I posted today at CTypes error loading DLL that calls another DLL. I posted this as a separate post because the problem is in dependencies with the Python C/API, not in the source code that I posted there.

I have a 64-bit NASM dll that calls a 64-bit C dll on Windows 7. The C dll uses the Python C/API; the NASM dll is called using CTypes. However, when I load the NASM dll using ctypes in Visual Studio, I get the error "[WinError 126] The specified module could not be found." The C dll was compiled using GCC in MSYS2.

Calling the NASM dll into Dependency Walker showed that libpython3.6m.dll and libwinpthread-1.dll were missing. Those dlls are in the distribution for MSYS2, so I copied them from there into the folder containing the NASM dll. That fixed that problem, but now Dependency Walker says it's missing all these DLLs:

API-MS-WIN-CORE-COM-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL
DCOMP.DLL
IESHIMS.DLL

This problem appears to be related to the Python C/API, which apparently depends on these DLLs. Does anyone know how to fix this? The full source code is at the link above.