Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    How do I selective static compile Qt application on Windows?

    Installation and Deployment
    4
    5
    3075
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      zither last edited by

      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

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        Hi zither,

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

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • V
          vsorokin last edited by

          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

          --
          Vasiliy

          1 Reply Last reply Reply Quote 0
          • Z
            zither last edited by

            @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

            1 Reply Last reply Reply Quote 0
            • G
              goetz last edited by

              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.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply Reply Quote 0
              • First post
                Last post