8

I have written a program with Qt5.3.1 and run it on my development machine where it works fine. I copied all necessary .dll files into the folder where my .exe is. These are:

  • Qt5Widgets.dll
  • Qt5Network.dll
  • Qt5Gui.dll
  • Qt5Core.dll
  • icudt51.dll
  • icuin51.dll
  • icuuc51.dll
  • libgcc_s_dw2-1.dll
  • libwinpthread-1.dll
  • libstdc++-6.dll

Now I want to run that program on a machine that has no Qt installed. How do I do that? It shouldn't be necessary for users to install an IDE just to use a program, right?

Details of the development machine where it works:

  • Windows 8
  • Qt 5.3.1

The deploying platform is:

  • Windows Vista
  • No Qt installed but all necessary .dlls are in place

Errors I get are first:

This application failed to start because it could not find or load the Qt platform plugin "windows". Reinstalling the application may fix this problem.

Next error message is:

This application requested the Runtime to terminate in an unusual way. Please contact support.

Then the program crashes. But if I install Qt5.3.1 it works. So it has something to do with files in the c:/Qt directory

D4rth B4n3
  • 1,268
  • 2
  • 17
  • 26
  • 1
    Also, there is [official guidance](http://qt-project.org/doc/qt-5/windows-deployment.html) on this available on the Qt website. – JBentley Jul 17 '14 at 01:30
  • I know and i did google it but the guide assumes that Qt is installed and that is exactly what my problem is. And sorry for the bad description. edited it – D4rth B4n3 Jul 17 '14 at 01:56
  • Thanks for the edit. I removed my downvote. If you scroll down that page to the section headed "Creating the Application Package", it contains instructions for deploying to a machine that does not have Qt installed. In particular, pay attention to the part about plugins as this is specific to your error message. I use these instructions myself for deploying Qt apps and can confirm that they work. – JBentley Jul 17 '14 at 03:26
  • Possible duplicate of http://stackoverflow.com/questions/1011197/qt-static-linking-and-deployment – László Papp Jul 18 '14 at 06:09
  • [This answer](http://stackoverflow.com/a/22492023/1329652) graphically illustrates what you need to do. And don't forget to install the MSVC redistributable, too! – Kuba hasn't forgotten Monica Jul 21 '14 at 17:09

8 Answers8

8

This application failed to start because it could not find or load the Qt platform plugin "windows".

For this problem, you should copy the plugin {QTSDK}/plugins/platforms/qwindows.dll to {YOUR_EXE_DIR}/platforms/qwindows.dll.

user3790229
  • 196
  • 5
  • i did the error message changed to : libwinpthread-1.dll is either not designed to run on windows or it contains an error. Try installing the program again using the original installation media or contact support. – D4rth B4n3 Jul 17 '14 at 03:57
  • I ran into this same problem and similar error messages on other DLLs created by windeployqt.exe. For anyone else that gets here, I was able to just copy the defective dlls manually from the qt bin folder (e.g. C:\Qt5.3.0\5.3\mingw482_32\bin) and then the resulting folder ran correctly. – Tod Sep 01 '14 at 01:57
7

The short answer is you either need to do a static build, or you need to redistribute the Qt shared library DLLs. If you're looking for a smaller file size static builds are often better, but there may be legal implications with this approach if you're using Qt5 under a LGPL license. I'm not a lawyer, but you can read about LGPL linking rules in LGPL section 4.1.

The long answer is you should read the general Qt5 deployment guide and the Qt5 for Windows deployment guide. These go into quite a bit of detail.

MrEricSir
  • 8,044
  • 4
  • 30
  • 35
  • 1
    Note: a not always understood implication of 4(d)(0) of the LGPL is that you do not have to distribute all of your source code in order to link statically. You merely have to supply the user with the ability to re-link to a new or different version of the library. This could be achieved in different ways e.g. supply compiled object files so that the user can re-link, or create a dynamic wrapper library and statically link Qt into that, then release the source for your wrapper. With that said, it is by no means trivial to achieve static linking with Qt and appears to be little supported. – JBentley Jul 17 '14 at 03:33
3

I have encountered this problem as well,

In your Qt Directory, with the proper Qt version C:\Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\platforms\

copy qwindows.dll into a new folder that lives next to your executable, such that your list would be

  • Qt5Widgets.dll
  • Qt5Network.dll
  • Qt5Gui.dll
  • Qt5Core.dll
  • icudt51.dll
  • icuin51.dll
  • icuuc51.dll
  • libgcc_s_dw2-1.dll
  • libwinpthread-1.dll
  • libstdc++-6.dll
  • platforms/qwindows.dll
Dart
  • 103
  • 1
  • 5
3

A better solution is to use the Qt SDK application "windeployqt". It is used to copy all the required dlls and plugins to your application folder based on target platform. You can then run that on another computer. Here is the documentation: https://doc.qt.io/Qt-5/windows-deployment.html.

For example, if your executable was built using mingw53_32 and your executable is in "C:\example_qtapp":

QT_INSTALL_DIR\minqw53_32\bin\windeployqt.exe c:\example_qtapp
jonspaceharper
  • 4,207
  • 2
  • 22
  • 42
JimSan
  • 915
  • 9
  • 19
  • one note - I had one person get dll missing errors for the following, which I had to manually copy from my computer into c:\example_qtapp folder: libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll – JimSan Aug 16 '18 at 20:26
  • Thanks for this answer - I've used qt for over two years, but I always had to compile it on Linux with MXE, if I wanted to use it outside my computer and I've never heard of this tool – Altinsystems Mar 25 '22 at 19:34
1

You should place Qt DLLs along the release version of your executable. These are Qt5Core.dll, Qt5Gui.dll and possibly the ones for other modules that you have used. These dll files are in your installed Qt Directory in bin folder. You should also place LIBGCC_S_DW2-1.DLL, MINGWM10.DLL and LIBSTDC++-6.dll in case you are using MinGW.

If you are using plugins you should place their dll in a folder named plugins beside your exe. In case of using icons and images you should ship their dlls like qico.dll and qsvg.dll in a folder named imageformats.

Nejat
  • 31,784
  • 12
  • 106
  • 138
0

if Qt dlls are there, they it should work. My guess is that you are missing the run time libraries/dlls of your IDE. For example, if you are using Visual Studio 2010 as your IDE, then you need to install VS2010 Redistributable x86/x64 link depends on your architecture.

Samer
  • 1,923
  • 3
  • 34
  • 54
0

You should also copy {QTSDK}/plugins to directory where you executable located. Then create qt.conf in the same place (with executable) with the following content:

[Paths]
Plugins=plugins

Thеn, run your program. I did the same on linux.

Kirill Mikhailov
  • 1,029
  • 9
  • 9
0

In your application folder hold down SHIFT key and right click from mouse. You will see - Open command window here

  1. Click Open command window here
  2. TYPE windeployqt.exe app_name.exe --parameters and HIT ENTER

Example:

windeployqt.exe APP_NAME.EXE --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-angle --no-opengl-sw
Razzak
  • 1
  • 2