1

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:

application dependencies

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?

mariusmmg2
  • 713
  • 18
  • 37
  • Self-answering questions are welcome on SO. But please seperate the question and the answer. You can edit the question so it contains only the question-part and post the solution as an answer. Otherwise this will look like an open issue and not like a solved problem. – Bowdzone Oct 22 '15 at 08:46
  • 1
    @Bowdzone Done. Thanks for noticing me. – mariusmmg2 Oct 22 '15 at 08:54

2 Answers2

8

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 environment PATH. The simplest deployment:

  • copy built exe binary to a new folder
  • open cmd console in that folder
  • call windeployqt using its full path (if it is not in the system PATH) and provide your executable, for example:
    c:\Qt\Qt5.5.1-vs2013-x64\5.5\msvc2013_64\bin\windeployqt.exe application.exe
    

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 of qml related files.

Only some 3rd party libraries should be copied manually if they are used, for example OpenSSL.

Orest Hera
  • 6,706
  • 2
  • 21
  • 35
  • This helped with most of my libs, but are the 3D modules an exception? For me, `windeployqt` seems to copy the Qt3D DLLs, but my resulting app is missing all the Qt3D QML modules. Am I suppose to deal with the QML modules separately? – Matt Feb 06 '17 at 22:33
  • *You do not even need to have your Qt bin folder in your environment PATH* note for future readers: I'm currently at Qt 5.11.2 and it's bin folder is not in my PATH. However, I do have a miniconda's installation Miniconda/LIbrary/bin in my path and that happens to have Qt dlls from a different version of Qt. Due to a bug in windeployqt it picks those dlls from the PATH even though it knows it has to pick the dlls from 5.11.2; it even prints it's doing that in the verbose output), yet it picks up the wrong dlls.. – stijn May 23 '19 at 09:30
1

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 from The application was unable to start correctly (0xc000007b) to Application 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 in Qt5.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.

Community
  • 1
  • 1
mariusmmg2
  • 713
  • 18
  • 37