So I have Visual Studio 2013 (community edition) with Qt addin installed, Qt5 libraries (32bit), and I'm trying to create an executable that is independent of all development configurations (it may use static or shared libs, I don't really care at this point).
OS: Windows 7, x64.
For doing this I changed the Solution Confguration
visual studio option from Debug
to Release
, and add all the necessary libs in Configuration Properties -> Linker -> Input -> Additional Dependencies
. The application now starts only if I run it from visual IDE, If I try to start it from the generated .exe
I got The application was unable to start correctly (0xc000007b)
error.
I have searched and found that this error code indicates one of the following problems:
- 32-bit app tries to load a 64-bit DLL (not my case I think, Qt DLLs are 32bit (I have installed using this .exe:
qt-opensource-windows-x86-msvc2013-5.5.0
.), and I use some other .DLLs which are also 32bit). - There are some missing DLLs. (I did copy all the necessary Qt DLLs in the same folder with the final executable).
For checking what dependencies my app requires, I opened the .exe
file with Dependency Walker application, this is what it shows me:
in this list were also Qt5Multimedia.dll
and Qt5SerialPort.dll
, I get rid of the errors by copying the .DLLs
in the same folder with the .exe
.
Any ideas how to solve this?
Solution:
As I got deeper, I have found this answer, after doing what that answer indicates (I actually copied all the
.DLLs
located in\Qt5.5.0\5.5\msvc2013\bin
to the folder where my.exe
is located), the error message changed fromThe application was unable to start correctly (0xc000007b)
toApplication failed to start because it could not find or load the QT platform plugin “windows”
.Searching on web for more about this error, I have found from this answer that you also need the
platforms
folder in the same location with the.exe
(which was located inQt5.5.0\5.5\msvc2013\plugins
path). After copying that folder, the application started without any problems!!!Now I just need to delete all unnecessary
.DLLs
from my application folder (Dependency Walker does not offer very useful information about this), and all the deployment is done.I have solved the problem in the same time as describing it, so I guess I will just leave this here, may help others that have the same problem.
You should never do that operation manually unless the standard procedure completely fails. There is already standard tool for Qt Windows deploymend
windeployqt
.It takes care about Qt DLL dependencies, makes a copy of
platforms\qwindows.dll
and also it makes a copy of libraries that you cannot detect with the Dependency Walker, since image plugins and some other are loaded at runtime.You do not even need to have your Qt
bin
folder in your environmentPATH
. The simplest deployment:exe
binary to a new foldercmd
console in that folderwindeployqt
using its full path (if it is not in the systemPATH
) and provide your executable, for example:As a result you have in that folder all needed Qt DLLs. Of course you can have also issues with MSVC redistributables, but those should be deployed separately and installed once per system.
The tool
windeployqt
has various options. It can also take care about deployment ofqml
related files.Only some 3rd party libraries should be copied manually if they are used, for example OpenSSL.