无法从 ctypes 加载库

Can't load library from ctypes

我想使用 python 的 C++ API。 我拥有的文件是 XX.dll、XX.lib 和 XX.h

我唯一的信息是:

Notes: To use the XX functions inside your C++ project you must integrate the XX Object file library "XX.lib" and XX header file "XX.h". The XX DLL must be add in your computer environment but not necessarily in the same folder of the Visual Studio project.

天真地我尝试获取 .dll 并使用 ctypes.cdll.LoadLibrary("XX.dll") 但是当我这样做时 python 尝试(但失败)加载 mscvr90.dll.

我认为mscvr90.dll的问题与有关,但我不知道如何解决

我找到了一个快速修复方法。 显然,这个想法是使用“mt.exe”将清单合并到 dll 中。

清单“XX.dll.manifest”

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

需要的命令是 mt.exe -manifest XX.dll.manifest -outputresource:XX.dll;2