Deploying a C++ Qt Application to another Computer
-
Hi there,
I'm new to Qt and currently switched from C# to C++ & Qt Programming.
For learning and testing Qt i just wrote an Password Generator.
I wanted to put the executable to another machine and run the exe file.
Alot of messageboxes did appear and wanted alot off DLL Files.
It did copy these files into the application directory. Now the Program runs.
The .exe file has only a size of 789 kb. But with all the DLL Files, the hole directory
is about 1,3 GB!!!! Just for an Password Generator!Is there anywhere an tutorial, how to find out which dlls are really necessary and
how to put the application onto another machine. I mean, i dont want to
put all these dll in every application i'm publishing, is there an smarter way like
putting these files into an special directory and every qt application will use these
dll files from this directory?Best Regards
-
To check the dependencies of a EXE-file you can use "Dependency Walker":http://www.dependencywalker.com/
But in your case (1.3GB overall) ther went something wrong :)
You should only need QtCore and QtGui dlls .. so your application shouldn't be larger than 20MB.
Either you linked against unecessary libraries or you just copied too much unnecessary files.How does your PRO-File look like (if you use qmake for building)?
-
Dependency Walker is a great tip, thanks alot!
Ok, i just deleted all dll files in the directory and let dependency walker run. It says i just need following dll files:- LIBGCC_S_SJLJ-1.dll
- LIBSTDC++-6.DLL
- QT5CORED.DLL
- QT5GUID.DLL
- QT5WIDGETSD.DLL
Just copied these files in the exe dir and the size is now 336 MB (Still big, but much better than 1,3 GB xD).
The exe does not run with only these dll files. When i want to start the executable i',m getting alot of errors like: icuin49.dll is missing. THere are much more dlls when i copy this one in the directory. At least the size will be 1,3 GB again when i copy all these files into the exe directory :-/
-
Pro File looks like this:
@#-------------------------------------------------Project created by QtCreator 2013-04-12T15:55:21
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = PasswordGen
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui@
-
to get rid of the LIBGCC_S_SJLJ-1.dll you can add the following line to your pro-File:
QMAKE_LFLAGS += -static-libgccWhat are the other missing DLLs? I think your other computer is just missing some runtime libraries thats why your have to copy to many files.
-
Have you tried using Qt 4.8 instead? Qt5 is only useful for writing QML apps for mobile devices, because nokia/digia have sacrificed alot for the cash they expect from that market. And what you're experiencing is just that. For example, by default even a normal desktop application now requires the OpenGL ES and WebGL libraries (ES stands for embedded systems) and DirectX HLSL compiler libraries. The hoops you have to jump through to use Qt5 are described "here":http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html.
Try Qt4.8, include QtGui.dll and QtCore.dll, and you'll be much happier. -
DerManu, I really hope you are wrong, but I have this nasty suspicion that you aren't...and I've just upgraded all my working machines to Qt5.0.2...
-
OK, so after my previous post, I panicked and ran to my Windows Qt machine...and noticed that there is a massive difference between the sizes of the release .dll's and the debug .dll's. For example, Qt5Cored.dll is ~75MB whereas Qt5Core.dll is (only) ~4MB.
@MarcoG88 - Judging from your post:
[quote author="MarcoG88" date="1365946879"]
- QT5CORED.DLL
- QT5GUID.DLL
- QT5WIDGETSD.DLL
[/quote]
I take it you compiled in debug (hence the xxxD.dll dependencies). If you compile in release, the dependencies will be the same (in the sense that you'll need Qt5CoreX, etc etc), but the size of the .dll's will be significantly reduced.
So although there are still a lot of dependencies and your distributable's size may still be larger than hoped or desired, it isn't quite as bleak as it seemed at first glance :)
-
-
DerManu, seems my preliminary optimism was misplaced. I can't even resolve all the new dependencies...on the verge of reverting back to 4.8.x.
-
Hi hsrt.
Welcome to DevNet.
Usually i'd recommend start new topic and not post questions into old threads. But your question is so popular that you can find answer, just by searching in forum :) .
Take a look to those great manuals:
"Deploying Qt Applications":http://qt-project.org/doc/qt-5/deployment.html
"Deploy_an_Application_on_Windows":http://qt-project.org/wiki/Deploy_an_Application_on_Windows -
Hi,
No need to build statically (there's also licensing issues that you must first take a look at before releasing an application using a static Qt)
The second link of qxoz shows how to prepare the necessary dlls besides your application executable.