Qt5应用程序部署qwindows.dll搜索路径顺序 [英] Qt5 application deploy qwindows.dll search path order

查看:1754
本文介绍了Qt5应用程序部署qwindows.dll搜索路径顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个文件夹中使用所需的DLL部署我们的应用程序。
加上平台文件夹中的qwindows.dll。



这真的太棒了,也没有任何Qt安装的机器。



直到昨天,当我更新我的Qt到5.5.1。
现在所有使用Qt 5.5.0构建的应用程序停止工作,并显示众所周知的错误:无法找到或加载Qt平台插件'windows'。



当我将Qt文件夹(C:\ Qt)重命名为其他内容时,一切正常。



进一步调查Dependancy Walker应用程序确实查找到我的C:\ Qt文件夹找到平台dll。但它们发现一个更新的/不同的版本并抛出错误。

  GetProcAddress(0xxxx [ADVAPI32.DLL],SystemFunction036)来自地址0xxxx处的MSVCR120.DLL,并返回0x00007FFB269C1050。 
从地址0xxxx处的QT5CORE.DLL调用LoadLibraryW(C:\Qt\5.5\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
在地址0xxxx处加载QWINDOWS.DLL。已成功挂接模块。
在地址0xxxx处加载WINMM.DLL。已成功挂接模块。
在地址0xxxx处加载OLEAUT32.DLL。已成功挂接模块。
在地址0xxxx处加载WINMMBASE.DLL。已成功挂接模块。
在地址0xxxx处加载DEVOBJ.DLL。已成功挂接模块。
在地址0xxxx处卸载QWINDOWS.DLL。
在地址0xxxx处卸载OLEAUT32.DLL。
在地址0xxxx处卸载WINMM.DLL。
在地址0xxxx处卸载WINMMBASE.DLL。
在地址0xxxx处卸载DEVOBJ.DLL。
LoadLibraryW(C:\Qt\5.5\msvc2013_64\plugins\platforms\qwindows.dll)返回NULL。错误:Die angegebene Prozedur wurde nicht gefunden(127)。

现在,如果C:\ Qt文件夹被重命名,应用程序不会找到它并在./platforms/中使用qwindows.dll。



现在的问题是,这种行为是否需要?
不应该首先在应用程序目录中搜索,然后再搜索别的地方?
是否有可能改变这种行为?

解决方案

我发现一个适合我需要的答案。 >

有可能将一个 qt.conf 文件放置在与部署的exe相同的目录中。在这个文件中,你可以这样指定插件目录:

  [Paths] 
Plugins =。

这意味着Qt只会搜索插件!在这个文件夹。
在这个例子中, qwindows.dll 需要在平台/我们习惯。



,因为我有qt的dll和插件完全分离的每个应用程序,我想部署。安装的Qt版本不会再干扰了。



一个真正详细的写作可以在这里找到: http://www.tripleboot.org/?p=536 在由Qt本身加载的DLLs aka插件:中。


I am deploying our applications with needed DLLs in the same folder. plus qwindows.dll in platforms folder.

That works really great, also machines without any Qt installations.

Until yesterday, when I updated my Qt to 5.5.1. Now all applications which where once build with Qt 5.5.0 stopped working and are showing the well known error: "could not find or load the Qt platform plugin 'windows'".

When i rename my Qt folder (C:\Qt) to something else, everything works again.

Further investigation with Dependancy Walker showed that the applications indeed look into my C:\Qt folder to find the platforms dll. but they find a newer/different version and throw errors.

GetProcAddress(0xxxx [ADVAPI32.DLL], "SystemFunction036") called from "MSVCR120.DLL" at address 0xxxx and returned 0x00007FFB269C1050.
LoadLibraryW("C:\Qt\5.5\msvc2013_64\plugins\platforms\qwindows.dll") called from "QT5CORE.DLL" at address 0xxxx.
Loaded "QWINDOWS.DLL" at address 0xxxx.  Successfully hooked module.
Loaded "WINMM.DLL" at address 0xxxx.  Successfully hooked module.
Loaded "OLEAUT32.DLL" at address 0xxxx.  Successfully hooked module.
Loaded "WINMMBASE.DLL" at address 0xxxx.  Successfully hooked module.
Loaded "DEVOBJ.DLL" at address 0xxxx.  Successfully hooked module.
Unloaded "QWINDOWS.DLL" at address 0xxxx.
Unloaded "OLEAUT32.DLL" at address 0xxxx.
Unloaded "WINMM.DLL" at address 0xxxx.
Unloaded "WINMMBASE.DLL" at address 0xxxx.
Unloaded "DEVOBJ.DLL" at address 0xxxx.
LoadLibraryW("C:\Qt\5.5\msvc2013_64\plugins\platforms\qwindows.dll") returned NULL. Error: Die angegebene Prozedur wurde nicht gefunden (127).

Now, if the C:\Qt folder is renamed, the application doesn't find it there and uses qwindows.dll in ./platforms/ like it always should.

Now the question is, is this behavior desired? Shouldn't it first search in the application directory, before searching somewhere else? Is there a possibility to change this behavior?

解决方案

I found an answer that suits my needs.

there is a possibility to put a qt.conf file in the same directory as the deployed exe. In this file you can specify the plugins directory like this:

[Paths]
Plugins=.

This means that Qt will search for plugins only! in this folder. In this example the qwindows.dll needs to be in platforms/ like we are used to.

This works perfectly for me, because i have the qt dll's and plugins totally separated for each app i want to deploy. And the installed Qt versions don't interfere anymore.

A really detailed write-up can be found here: http://www.tripleboot.org/?p=536 in section "DLLs loaded by Qt itself a.k.a. plugins:"

这篇关于Qt5应用程序部署qwindows.dll搜索路径顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆