I've looked at the example given here ctypes - Beginner and followed the same steps with a different bit of C code. I've built a .dll and a .lib using C code given here: http://wolfprojects.altervista.org/articles/dll-in-c-for-python/
//test.c
__declspec(dllexport) int sum(int a, int b) {
return a + b;
}
In my wrapper.py I have this:
import ctypes
testlib = ctypes.CDLL("C:\\Users\\xyz\\Documents\\Python\\test.dll")
When I run the script I get this error:
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
If I use
testlib = ctypes.LibraryLoader("C:\\Users\\xyz\\Documents\\Python\\test.dll")
then I don't get any error on running the script. But If I try to do this:
testlib.sum(3,4)
I get the error:
dll = self._dlltype(name)
TypeError: 'str' object is not callable
The dll and the .py are in the same folder. Can anyone help me understand what's going on here. I've spent hours trying to figure this out, but have hit a wall. Thanks.