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



  • Hi zither,

    I can't beleive that. Do you look at release build? Debug might be huge, but release should be some kB.



  • AFAIK no way.

    But you can:

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

    1. use "UPX":http://upx.sourceforge.net/ for compressing.
    2. 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.