LoadLibrary 失败并且依赖遍历器没有帮助
我尝试使用 QtSql 的 QOCI 插件,直到遇到一些问题: 为什么 QOCI 插件不起作用
但事实证明这是一个库加载问题(至少我是这么认为的),所以我决定改变问题的主题,因为这是一个新问题。
我有一个 dll 文件(称为 qsqloci4.dll),当我尝试使用 LoadLibrary 加载它时,它失败并且 GetLastError 返回 ERROR_MOD_NOT_FOUND。当我尝试使用 LoadLibraryEx 加载它并且第三个参数是 DONT_RESOLVE_DLL_REFERENCES 时,它加载成功(不返回 NULL)。
所以,我认为这是一个依赖性问题。我用dependency walker打开dll文件,有2个文件无法定位:QtCore4.dll和QtSql4.dll。 但是,这些文件位于应用程序的工作目录中,并且依赖于这些dll的其他dll文件(例如qsqlpsql4.dll)已成功加载。
其他 dll(由依赖项 walker 定位)是:
- oci.dll :与 QtCore4.dll 和 QtSql4.dll 位于同一文件夹中,意味着我的应用程序可以访问它
- 可以找到最简单的 dll
- kernel32.dll :我相信我的应用程序msvscr80 .dll :使用此的其他dll文件可以成功加载。
这是我的问题:给定依赖 Walker 说:“你拥有除 qt 之外的所有 dll”,并且我确信我有 qt dll,还有什么其他原因可能导致 LoadLibrary 因 ERROR_MOD_NOT_FOUND 失败?
I was trying to use QOCI plugin for QtSql, until I had some problems:
Why QOCI plugin isn't working
However it turned out that it is a library loading issue (at least I think so), so I decided to change the subject of the question since it is a new question.
I have a dll file (called qsqloci4.dll) When I try to load it with LoadLibrary, it fails and GetLastError returns ERROR_MOD_NOT_FOUND. When I try to load it with LoadLibraryEx and 3rd parameter is DONT_RESOLVE_DLL_REFERENCES, it loads successfully (does not return NULL).
So, i thought it is a dependency issue. I opened the dll file with dependency walker, there were 2 files that couldn't be located: QtCore4.dll and QtSql4.dll.
However, these files are in the working directory of application, and other dll files which are dependent on those dlls (such as qsqlpsql4.dll) are successfully loaded.
Other dlls (which are located by dependency walker) are:
- oci.dll : is in same folder as QtCore4.dll and QtSql4.dll, means my app can access it
- kernel32.dll : i believe the easiest dll to locate by my app
- msvscr80.dll : other dll files which use this can be loaded successfully.
Here is my question: given dependency walker says : "you have all dlls except qt ones" and i am sure that I have qt dlls, what other reason can be for LoadLibrary to fail with ERROR_MOD_NOT_FOUND?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在动态模式下运行 Dependency Walker,因为有些依赖项将通过显式链接来解决。我相信您可以从“个人资料”菜单中执行此操作。
You need to run Dependency Walker in dynamic mode because the are some dependencies that will be resolved by explicit linking. I believe that you do this from the Profile menu.