3

I'm new to Qt and cannot figure out how to deploy a simple Qt application on Windows. It runs fine when run from inside Qt Creator, but it won't run when directly executed. I have the newest version of the Qt SDK installed and am using all of the default settings.

I have read dozens of "how to" guides, all of which provided conflicting information, in addition to dozens upon dozens of forum threads, blog posts, and questions on here. I simply cannot find instructions that clearly explain how to deploy a Qt application on Windows.

I tried putting all the DLLs I could find in the application directory, but that didn't work. I also tried building Qt statically, but that didn't work either.

Can anyone help me out?

EDIT: Thank you both for your replies. Here is some additional information:

I am using "Qt Creator 2.4.1, Based on Qt 4.7.4"

I have the following includes across different files:

#include <QtGui/QApplication>
#include <QDebug>
#include <QTextEdit>
#include <QtGui>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include "qthread.h"
#include "windows.h"
#include <QMessageBox>

I'm using the default compiler that came with Qt, MinGW.

Stals
  • 1,543
  • 4
  • 27
  • 52
Nate
  • 26,164
  • 34
  • 130
  • 214

2 Answers2

1

The simple solution is to include the Qt dlls with your deployment, placing them in the same location as the executable. Be aware that Qt uses different dlls for release vs. debug builds, so don't accidentally deploy a debug build.

Using static libraries is also viable. Your edit states you've tried both static and same-directory deployment. If neither of these (especially the static build) are working, you're doing something seriously wrong and it's rather difficult to debug over a board like SO.

mah
  • 39,056
  • 9
  • 76
  • 93
0

First of all, please post the details like

Which qt version you are working on? What modules are you using - QtNetwork, QTGui etc ?

Lastly what compiler are you using, MinGW, MSVC ?

All you need to do is deploy QTCore dll and other dlls for modules you have included in your project in the application directory.

Further, if you are using MSVC compiler, you will have to deploy MSVC runtime. You can find the redistributable on the microsoft website.

Alternatively if you are using mingw then you might need to deploy proper g++ runtime.

If you are still unable to deploy the application with above information, provide the additional details so I can suggest the correct way.

Murtuza Kabul
  • 6,438
  • 6
  • 27
  • 34
  • I added more details, thanks. I also tried copying every .dll from `E:\Qt\QtCreator\bin` to my application folder, but it will not run. – Nate Oct 08 '12 at 03:05
  • Can you please post the error you are getting while trying to execute the application. If you are unable to see any errors, try searching the windows application event log. It should be specifying the exact error. Further when you deploy the application, you will also have to put the mingw runtime which will not be in the qt directory. Put the dll "mingwm10.dll" in the deployment folder also. – Murtuza Kabul Oct 08 '12 at 03:08
  • I did a search for "mingwm10.dll" in the Qt directory and there are eight results with some of the file sizes being different. Which one should I use? – Nate Oct 08 '12 at 03:12
  • I was expecting a couple of files but as you have eight, I am a bit confused. Honestly, I use MSVC compiler so it has never been a question for me. I know it is a dirty way but try putting them one by one in the application folder and the one which works for you is your file. If you could have posted the event log, it would have been quite easy. – Murtuza Kabul Oct 08 '12 at 03:18
  • OK, so I copied over *every* dll from `E:\Qt\Desktop\Qt\4.8.1\mingw\bin`, as well as mingwm10.dll from `E:\Qt\Desktop\Qt\4.8.0\mingw\bin`. Now when I double click the application, there is not error message, but it does not run and a Windows dialog comes up saying "[appliation name].exe has stopped working ..." So something is wrong. – Nate Oct 08 '12 at 03:18
  • Humm.. , please see the windows event log and post the details. Now I think there is an issue in the application code itself. – Murtuza Kabul Oct 08 '12 at 03:19
  • My Computer > Manage > Event viewer > Windows logs > Application, it will have the details of last error occured – Murtuza Kabul Oct 08 '12 at 03:20
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/17680/discussion-between-murtuza-kabul-and-nate) – Murtuza Kabul Oct 08 '12 at 03:22
  • I joined the chat, but you don't seem to be there? – Nate Oct 08 '12 at 03:29