Qt5 application deploy qwindows.dll search path order

Issue

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?

Solution

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:”

Answered By – Stefan Menzel

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published