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.

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

OK, so forgetting the static build for now, how can I get it to run stand alone?
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.

9 Comments

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.
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.
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?
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.
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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.