I'm trying to call C++ from Python.
import ctypes
clibrary = ctypes.WinDLL("C:/Users/Desktop/SOURCE/build/libmy_library.dll")
my_library.hello_world()
I am most certainly sure that my_library.dll
path is exactly correct. But I still get this error:
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\Desktop\SOURCE\build\libmy_library.dll' (or one of its dependencies). Try using the full path with constructor syntax.
What is wrong here?
Note: If it matters my cmake is "Unix Makefiles". And I don't use visual studio, I use VS code.
Edit: Dependency Walker
Error: At least one required implicit or forwarded dependency was not found. Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found. Error: A circular dependency was detected. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
EDIT This really fixed it:
dll_name = "C:/Users/Desktop/SOURCE/build/libmy_library.dll"
dll_handle = win32api.LoadLibraryEx(dll_name, 0, win32con.LOAD_WITH_ALTERED_SEARCH_PATH)
my_lib = ctypes.WinDLL(dll_name, handle=dll_handle)