3

I have made an QT programm that I want to be able to run on another computer that doesnt have QTsdk installed on it. So I guess I have to make an executable file. Unfortunately I have abolutely no experience with this. Can somebody tell me how to do this in simple words?

I work have made the programm in Qt Creator 2.4.1 based on Qt 4.7.4 (32 bit) on a windows 64bit computer.

5
  • "So I guess I have to make an executable file" Surely you have a running program already?
    – cmannett85
    Aug 28, 2012 at 10:37
  • Yes I do, but to show the program I just hit the "run" button in QT without actually knowing what this really does...
    – Frank
    Aug 28, 2012 at 10:39
  • 1
    It runs the application, the only difference between what hitting "Run" in Qt does and clicking on it in Windows, is that the program output is piped into Qt's console.
    – cmannett85
    Aug 28, 2012 at 10:43
  • 1
    The executable is in the build folder (found in the project's configuration in QtCreator), and there in one of the subfolders "debug" or "release". You also find the executable's path when hitting "run" in the output console within QtCreator (the blue line).
    – leemes
    Aug 28, 2012 at 12:40
  • Ah, this clears up a lot for me. Thx! So if I understand it right the program is compiled every time I hit the "run" button? Just wondering now what the difference is between letting it compile in the "debug" or "release" mode, but my primary question is awnsered :).
    – Frank
    Aug 28, 2012 at 16:16

3 Answers 3

3

On answer mentions statically linking your executable with the Qt libraries, this is very convenient as it means you only have a single file to deal with (your exe) - BUT because of Qt's licensing, it also means you have to buy a commercial license for your application.

Assuming you are not modifying Qt's source code, the way round this is to ship Qt's runtime libraries (the .dll files it needs for runtime linking) with your application. This is how the vast majority of programs on your machine work anyway because it has lots of other advantages too.

2
  • I dont have a commercial licence so I would like to try the second option you mention. I have found lots of info with commands as qmake, mingw32 etc but they all say something different and nothings has worked so far. Can you clearly state which steps I have to do?
    – Frank
    Aug 28, 2012 at 11:32
  • By default qmake dynamically links, so you are already compiling for that. So all you have to do put the Qt dll files you need (at least QtCore, and almost certainly QtGui, but only you know exactly what features you need), in a place that your target Windows machine can find them. That's usually in the same folder you intend on putting the executable, but I'm not much of a Windows user so there may be somewhere more appropriate - hopefully I've given you enough info to do some web searching to find the extra details you need. Good luck!
    – cmannett85
    Aug 28, 2012 at 11:45
3

Use Dependency Walker to find out what Qt and other runtime (MinGW) DLLs are required in your app. Copy those DLLs to the same folder as your app. Zip the folder and distribute the archive.

2
  • what do you mean with "app" in this case? If you mean an exe of the program I made, then I must ask you how I get this.
    – Frank
    Aug 28, 2012 at 12:35
  • 1
    Yes, it's exe in Windows land. App used to be the short hand for application (built binaries) until smart phones came along... Dependency Walker is linked in my answer. Aug 28, 2012 at 13:38
1

if you mean statical linking
http://doc.qt.nokia.com/4.7-snapshot/deployment.html#static-vs-shared-libraries

then there are tons of tutorials on the web
http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows
http://www.formortals.com/how-to-statically-link-qt-4/

it's just about configuring your qmake file with static flags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.