How do I selective static compile Qt application on Windows?
-
Dear all,
I would like to make static compile for Qt on Windows. The main problem is huge size of EXE file.
I just use QDialog, QLabel, QTextEdit and some others. How can I selective link to these classes which I used.
If I link to Whole QtGui, it all include in my EXE which make huge in file size.
Thanks
-
AFAIK no way.
But you can:
- build minimal Qt with this params for example:
bq. configure -release -static -no-accessibility -opensource -no-sql-sqlite -no-qt3support -no-opengl -no-openvg -no-libmng -no-libtiff -no-libjpeg -no-dsp -no-vcproj -openssl-linked -no-dbus -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-webkit -no-script -no-scripttools -no-declarative -no-declarative-debug
- use "UPX":http://upx.sourceforge.net/ for compressing.
- use msvc, it give less size of exe file instead mingw
-
@Gerolf
Yes, it's release build. static compile of release for a EXE's size +4MB for a simple GUI.@Vass
The params which you give only reduce Qt lib size? for example, -no-sql-sqlite only exclude "qsqlite" module & it can't effect on EXE size unless I used that module in my EXE.I'll also try with msvc.
Is there any other optimization with mingw for static compilation?Thanks
-
4 MB for a statically linked hello world executable, which includes Qt lib stuff and C++ stdlib stuff, is not huge!
Leaving out some features in a static build does not reduce the size of the final executable in a noticeable way. By linking statically against the Qt libs, you will pull in only the object code that is needed to run your app.