Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How do I selective static compile Qt application on Windows?
Qt 6.11 is out! See what's new in the release blog

How do I selective static compile Qt application on Windows?

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 4 Posters 4.3k Views 1 Watching
  • 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 Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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
      0
      • V Offline
        V Offline
        vsorokin
        wrote on last edited by
        #3

        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
        0
        • Z Offline
          Z Offline
          zither
          wrote on last edited by
          #4

          @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
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved