dll调用,出现function not found错误
目前使用python调用dll程序,64位dll和32位dll是由相同的c/c++程序生成。extern "C" __declspec(dllexport) int Dll_F00007_USB_Platform_Start(uint16_t USBPort, uint16_t & Count)
在64bit的程序上运行成功
>>> import ctypes
>>> usbport=ctypes.c_uint16(0)
>>> count=ctypes.c_uint16(0)
>>> dev=ctypes.WinDLL(r'D:\560\DesignSources\3.GUI source\Code spec\S0003_F340_Control_Dll.dll')
>>> dev.Dll_F00007_USB_Platform_Start(usbport,ctypes.byref(count))
0
但是使用32bit的程序上调用总是出现function not found的错误,分别使用ctypes.WinDLL ,ctypes.CDLL,ctypes.windll.LoadLibrary,ctypes.cdll.LoadLibrary均尝试了
>>> import ctypes
>>> dev=ctypes.CDLL(r'D:\560\DesignDocuments\1.Software\0.module\python\python2_CIG\CredoPython\Device\dove_api.dll')
>>> usbport=ctypes.c_uint16(0)
>>> count=ctypes.c_uint16(0)
>>> dev.Dll_F00007_USB_Platform_Start(usbport,ctypes.byref(count))
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
dev.Dll_F00007_USB_Platform_Start(usbport,ctypes.byref(count))
File "C:\Users\chenhongwen\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "C:\Users\chenhongwen\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 391, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Dll_F00007_USB_Platform_Start' not found
>>> dev=ctypes.WinDLL(r'D:\560\DesignDocuments\1.Software\0.module\python\python2_CIG\CredoPython\Device\dove_api.dll')
>>> dev.Dll_F00007_USB_Platform_Start(usbport,ctypes.byref(count))
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
dev.Dll_F00007_USB_Platform_Start(usbport,ctypes.byref(count))
File "C:\Users\chenhongwen\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "C:\Users\chenhongwen\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 391, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Dll_F00007_USB_Platform_Start' not found
这个问题应该是因为程序当前的编辑运行环境不匹配, 因为64位的python.exe只能调用64位的DLL,32位的python.exe 只能调用32位的DLL。如果你用64位环境下的python调用32位的DLL文件肯定是不行的,要保证环境一致。具体请参照https://blog.csdn.net/weixin_39590566/article/details/113320798 有大神遇到类似的情况吗,怎么解决的 lucky邪神 发表于 2021-6-16 09:38
有大神遇到类似的情况吗,怎么解决的
把dll发出来看看 win64是64位
win32是32位
SiUSBXp.dll是标准的文件 请问你解决了吗 临时号 发表于 2021-7-21 14:13
这个问题应该是因为程序当前的编辑运行环境不匹配, 因为64位的python.exe只能调用64位的DLL,32位的python ...
我电脑上64为和32位的python,都有。后面问题解决了,dll改动后,目前64位和32位都可以使用
页:
[1]