【发布时间】:2015-08-05 14:21:24
【问题描述】:
我有一个依赖于其他一些(日晷 ODE 求解器).dll 的 .dll。我使用带有 mingw 的 windows 8.1 来编译和链接我用于 .dll 的 c 代码。当尝试使用 Python 和 ctypes 加载它们时,我得到一个带有 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 非常有经验。任何建议可能是什么原因?
【问题讨论】:
-
如果将
C:\sundials\instdir\lib添加到 PATH 会发生什么? -
这似乎很有魅力!伟大的安托,谢谢你的回答。如果您将其作为单独的答案发布,我会为您接受。