'Why does ctypes find my dll but not my function?
I am trying to rewrite an 32bit Matlab-script in Python. For this I need to include a dll, which I am trying to do with ctypes. Somehow the Python script does find the dll, but not the function I am searching for. I know the name of the function, because I have got the separate header-file and already used that function in my Matlab-script.
from ctypes import cdll
xxx = cdll.LoadLibrary('C:\\Users\\Marco\\Software\\Python\\xxxdllio.dll')
res=xxx.xxxdll_set_comm()
The terminal says:
AttributeError: function 'xxxdll_set_comm' not found
The following is a clip out of the dlls header-file:
*// usage: xxxdll_set_comm(hex_num, func , data);
I am fairly new to Python, so have no idea, why my Matlab-script finds this function and my Python-script not.
Solution 1:[1]
Thanks alot tdelaney, after a couple of hours now, i managed to get it running, because of your tip. I installed a few older versions of visual studios but never managed to find dumpbin. If you download Visual Code 2017 Professional Edition with the C++ MSVC Buildtools, you can find under the following location dumpbin.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\dumpbin.exe
After opening the Developer Command Prompt and changing the directory to the dlls location, i got the following output:
Dump of file xxxdllio.dll
File Type: DLL
Section contains the following exports for xxxdllio.dll
00000000 characteristics
0 time date stamp
0.00 version
1 ordinal base
13 number of functions
13 number of names
ordinal hint RVA name
1 0 000088D0 @__lockDebuggerData$qv
2 1 000088F8 @__unlockDebuggerData$qv
3 2 000034CA @xxxiodll_scan_get$qpus
4 3 000034F2 @xxxiodll_scan_get_long$qpui
5 4 00008205 @xxxiodll_set_comm$qiii
6 5 00008243 @xxxiodll_set_comm_ptr$qiipv
7 6 00008235 @xxxiodll_var_get_float$qui
8 7 000147F0 __DebuggerHookData
9 8 000034CA xxxiodll_scan_get
10 9 000034F2 xxxiodll_scan_get_long
11 A 00008205 xxxiodll_set_comm
12 B 00008243 xxxiodll_set_comm_ptr
13 C 00008235 xxxiodll_var_get_float
So it looks like i was missing an "io" in my functions name.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
