我有一个.dll,它依赖于其他.dlls (Sundials )。我使用Windows8.1和mingw一起编译和链接用于我的.dll的c-代码。当试图用Python和ctype加载它们时,我会弹出一个System error: cannot find libsundials_cvode.dll since it does not exist on the computer,当您关闭弹出Python时,WindowsError: [Error 126] Cannot find the module无法理解为什么会这样,因为gcc编译和链接文件时没有错误(是的,它们确实存在).我甚至尝试将依赖的dll复制到python脚本所在的目录中,但没有成功。
我运行以下编译和链接器命令,没有任何警告或错误
gcc -c -I c:\sundials\include cfile.c
gcc -shared -o clib.dll cfile.o -L. C:\sundials\instdir\lib\libsundials_cvode.dll -L. C:\sundials\instdir\lib\libsundials_nserial.dll给出上述错误的python测试脚本是
import ctypes
lib = ctypes.cdll.LoadLibrary('clib.dll')我是gcc和c的初学者,但对Python很有经验。有什么建议吗?原因是什么?
发布于 2015-08-06 20:29:31
见维基百科动态链接库
"...Unless您的DLL是一个组件对象模型(COM)服务器,该DLL文件必须放在PATH环境变量中列出的目录之一、默认系统目录或与使用它的程序相同的目录中.“
因此,将C:\sundials\instdir\lib添加到PATH env中。变量。
https://stackoverflow.com/questions/31835213
复制相似问题