I’m using ctypes for the first the first time and thus was playing around with it before trying to actually implement it. However, I’m unable to load my compiled DLL using ctypes.CDLL()
as it throws a FileNotFoundError. This is the complete error: FileNotFoundError: Could not find module 'E:absolutepathto.dll' (or one of its dependencies). Try using the full path with constructor syntax.
. I am certain that the file exists at that location.
Looking it up, it was suggested that I used Dependency Walker to track any dependencies that might have not been compiled, but when I use it, it only marks the Windows API stuff (which, based on what Google says, is normal? I’m using a Windows 10 system), nothing else. Which I think makes sense as this is the entirety of the C++ code:
#include <string>
#include <cstring>
using namespace std;
extern "C" {
const char* formatIntegerMessage(int num) {
// code implementation
}
}
And here’s the python code where I attempt to use it
import ctypes
lib = ctypes.CDLL("C:/absolute/path/to.dll") # throws the FileNotFoundError
# more code
I also tried adding from ctypes import *
and using ctypes.WinDLL()
instead of CDLL
, but each one throws the same error.
I’m sure I’m making an obvious mistake here, but I can’t find anything online about it. Any help would be greatly appreciated!