I have a c++ dll project in Visual Studio 2022, that is meant to be called from python with ctypes. However, while the release DLL loads fine, the debug one cant be found.
Traceback (most recent call last):
File "c:\...\RECURSIVE_NODES\python\gym_cartpole.py", line 25, in <module>
libc = ctypes.cdll.LoadLibrary(dll_path)
File "C:\miniconda3\lib\ctypes\__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "C:\miniconda3\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'c:\...\RECURSIVE_NODES\x64\Debug\RECURSIVE_NODES.dll' (or one of its dependencies). Try using the full path with constructor syntax.
The DLL exists, and the path is correct, I have checked it 10 times over. It just wont work. Python code is as follows :
from pathlib import Path
dll_path = 'c:\...\RECURSIVE_NODES\x64\Debug\RECURSIVE_NODES.dll'
sPath = Path(dll_path)
print(sPath.is_file()) # returns true for both release and debug DLLs , so the file exists and is found by pathlib !!
libc = ctypes.cdll.LoadLibrary(dll_path)
The ellipsis in the path omit irrelevant parts of it. When I replace "Debug" with "Release" in the above path, the dll is correctly loaded. Whats the problem here ?
SOLUTION
As @MarkTolonen said in the comments, “Or one of its dependencies”. I checked those in the developper command prompt with dumpbin /dependents RECURSIVE_NODES.dll, and one of the differences between Release and Debug was the Adress Sanitizer's dll. For some reason Visual Studio was not able to find it, even though I was using its own debugger. Thats not the first time aSan has caused me troubles, so I disabled it, recompiled and python now finds the dll.