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. Let's build small Qt libraries! (Step 2: Optimize build-settings)

Let's build small Qt libraries! (Step 2: Optimize build-settings)

Scheduled Pinned Locked Moved Installation and Deployment
36 Posts 6 Posters 23.2k Views
  • 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.
  • G Offline
    G Offline
    goetz
    wrote on 17 May 2011, 17:13 last edited by
    #10

    As you're on Windows using MinGW (I know your project quite good now :-) ) you must add the respective mkspec:

    @
    ./configure -platform win32-gcc ... your additional args go here ....
    @

    The rest of your no-xxx switches does not influence the size very significantly. It just leaves out the build of some submodules and the like, which you would not put into your final applications directory anyways.

    Be sure to create release libs (without debugging symbols), this decreases the size of the libs significantly!

    And finally you can try to run MinGW/bin/strip.exe on every executable and library (DLL) you have in your directory. I did not try this yet, but at least on Unix this reduces the size even more.

    For distribution, put it all in a ZIP. UPX and the like is not really useful IMHO. The exe and the libs must be decompressed eventually to run the program, thus slowing down the start up time of your application.

    Remember: Disk space is cheap :-)

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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on 17 May 2011, 17:26 last edited by
      #11

      @Volker: I thought so. But I am very surpised that somebody wants to compress binaries on the maximum in time when we have 2-3 TBytes harddisks (no everybody has terabytes harddrives, but 16MB is not so much...)...

      I am compiling under MSVC 2008 compiler and it's quite better than MinGW (IMHO)...

      BTW. What is the name of your project? :-)

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hedge
        wrote on 17 May 2011, 17:35 last edited by
        #12

        bq. As you’re on Windows using MinGW (I know your project quite good now :-) ) you must add the respective mkspec:
        ./configure -platform win32-gcc ... your additional args go here ....

        Just making sure. So I need to attach the compiler-switches like -fmerge-all-constants already in the configure-step?

        These are the Qt-dll's and their sizes my program currently needs:

        @Uncompressed size | UPX -9 size | Name

          2,43MB          |    0,91MB    | QTCore4.dll
          2,92MB          |    0,86MB    | QTDeclarative4.dll
          9,39MB          |    3,69MB    | QtGui4.dll
          1,15MB          |    0,40MB    | QTNetwork4.dll
          2,07MB          |    0,65MB    | QTScript4.dll
          0,20MB          |    0,10MB    | QTSql4.dll
          3,82MB          |    0,94MB    | QTXmlPatterns4.dll
        

         21,98MB              7,55MB@
        

        Especially QtGui4.dll should be reducable much further since I'm using exclusively QML (with Jens desktop-components) for the GUI.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Peppy
          wrote on 17 May 2011, 17:42 last edited by
          #13

          Quite big difference...but there is a good question: Do you need it? Will it help you as you are waiting? Has the binary compression any result on booting (I mean loading) time?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 17 May 2011, 17:50 last edited by
            #14

            The DLLs cannot be shrunk, unfortunately. They contain all the symbols of the module, even if you only need one of them. And QML of course depends heavily on the widgets in QtGui :-)

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

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Peppy
              wrote on 17 May 2011, 17:54 last edited by
              #15

              DLLs should get redesigned, this system is too old (from Windows 95, I think), but that's the work of Microsoft...

              1 Reply Last reply
              0
              • H Offline
                H Offline
                Hedge
                wrote on 17 May 2011, 17:55 last edited by
                #16

                So even qconfig won't help?
                I could exclude some widgets in the sourcecode but that is a bit too much (imagine I need to do this for every new qt-version).

                strip <file> -s didn't really do much. Any other useful parameters?

                What I am aiming for is a small download-size for users.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Peppy
                  wrote on 17 May 2011, 17:56 last edited by
                  #17

                  -o1, ..., -o5 for MinGW

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Hedge
                    wrote on 17 May 2011, 18:01 last edited by
                    #18

                    Where do I use these flags?

                    I initially asked where I can apply the compiler-flags:

                    bq. -Os
                    -fmerge-all-constants
                    -fno-default-inline
                    -fno-inline

                    Neither configure nor mingw32-make accept them.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on 17 May 2011, 18:01 last edited by
                      #19

                      [quote author="Peppy" date="1305654867"]DLLs should get redesigned, this system is too old (from Windows 95, I think), but that's the work of Microsoft...[/quote]

                      Shared libraries (.so on unix/linux, .dylib on Macs) behave just the same way! They were intended to reduce the memory footprint (a shared library is loaded into memory only once and used by multiple programs), as well as disk space. Both are not so an issue anymore these days.

                      So, a Mac application bundle is "bloated" too, as would be a linux archive containing all necessary non-system libraries.

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

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on 17 May 2011, 18:10 last edited by
                        #20

                        [quote author="Hedge" date="1305654933"]So even qconfig won't help?
                        I could exclude some widgets in the sourcecode but that is a bit too much (imagine I need to do this for every new qt-version).

                        strip <file> -s didn't really do much. Any other useful parameters?

                        What I am aiming for is a small download-size for users.[/quote]

                        No, qconfig does not help. The DLLs will always contain all widgets.

                        strip regularly does not save very much space on binaries compiled in release mode already.

                        If you're only after a small download size, use a decent archiver and set it's mode to maximum compression.

                        [quote author="Hedge" date="1305655290"]Where do I use these flags?

                        I initially asked where I can apply the compiler-flags:

                        bq. -Os
                        -fmerge-all-constants
                        -fno-default-inline
                        -fno-inline

                        Neither configure nor mingw32-make accept them.[/quote]

                        These are compiler/linker flags, you can try to set them for configure this way:

                        @
                        CFLAGS="-Os -fmerge-all-constants -fno-default-inline -fno-inline"
                        ./configure -platform win32-g++
                        your additional flags go here
                        @

                        But be aware that fiddling with optimization settings (-Os) may make things worse or add a runtime slowdown penalty.

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

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Peppy
                          wrote on 17 May 2011, 18:14 last edited by
                          #21

                          But they were designed about 20 years before, and probably they will change...

                          But back to the topic, I don't remember what it was...

                          I think: http://wiki.wxwidgets.org/Reducing_Executable_Size (--strip-all)

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            Hedge
                            wrote on 17 May 2011, 18:22 last edited by
                            #22

                            Thanks for clarifying that CFLAGS-thing. I'm currently writing my BA so I've got time to try some configurations (and also the MSVC-compiler).

                            I'll post the details here.

                            However I've a problem atm ...size-wise.
                            My application, although build in release-mode asks for the debug-DLLs as well (QtGui4d.dll etc.) when I try to execute it on another PC. Any ideas what would could've gone wrong?
                            The executables size is much smaller than in debug-mode (400kb vs. 2.4MB).

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Peppy
                              wrote on 17 May 2011, 18:25 last edited by
                              #23

                              Yes, executable is much more smaller than DLLs (who knows why?)...

                              Why that happens? Good question... Please make new thread, it's new question, and it'll going to off topic...

                              1 Reply Last reply
                              0
                              • H Offline
                                H Offline
                                Hedge
                                wrote on 17 May 2011, 18:31 last edited by
                                #24

                                There's already a thread "here":here http://developer.qt.nokia.com/forums/viewthread/6033/ regarding that question but no one had a good idea yet.
                                I threw it in b/c it didn't seem to be too off-topic (it's influencing the application-size in a very bad way).

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Peppy
                                  wrote on 17 May 2011, 18:39 last edited by
                                  #25

                                  Yes, but this topic is named as "Minimizing sizes of DLLs" not as "Issue with DLLs" ;) That's just detial, but that I've learnt on other board as moderator (just my habit :-D)

                                  Yes, it's quite strange...

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    deni-herdiman
                                    wrote on 17 May 2011, 20:15 last edited by
                                    #26

                                    [quote author="Hedge" date="1305656526"]
                                    However I've a problem atm ...size-wise.
                                    My application, although build in release-mode asks for the debug-DLLs as well (QtGui4d.dll etc.) when I try to execute it on another PC. Any ideas what would could've gone wrong?
                                    The executables size is much smaller than in debug-mode (400kb vs. 2.4MB).
                                    [/quote]
                                    if you're using UPX....
                                    try delete pagefile.sys of your compiler's pc, than run your apps than something going haven...
                                    sadly crash in previous trial... :(

                                    1 Reply Last reply
                                    0
                                    • H Offline
                                      H Offline
                                      Hedge
                                      wrote on 17 May 2011, 20:16 last edited by
                                      #27

                                      The problem was another dll build in debug-mode. Peppy found the solution in the thread mentioned above.

                                      1 Reply Last reply
                                      0
                                      • H Offline
                                        H Offline
                                        Hedge
                                        wrote on 18 May 2011, 10:45 last edited by
                                        #28

                                        I've got some results to show off.

                                        I can't run configure with the Microsoft-compiler ("Your text to link here...":http://developer.qt.nokia.com/forums/viewthread/6060/).

                                        For now I built Qt with the following configure-options:

                                        @Configure -L -release -platform win32-g++ -opensource -no-exceptions -no-stl -no-opengl -no-openvg -no-libjpeg -no-libtiff -no-dsp -no-vcproj -no-webkit -no-scripttools -no-native-gestures -qconfig ali@

                                        I checked off as much stuff as possible in my custom config-file but especially didn't know which GUI-components I could remove (I use the qml-desktop-components).

                                        The result is a lower size of around 1MB (6,51MB compared to 7,55MB before)

                                        @default size | self-compiled(gcc) | UPX -9 | Name

                                          2,43MB        |      2,04MB        |    0,80MB    | QTCore4.dll
                                          2,92MB        |      2,23MB        |    0,67MB    | QTDeclarative4.dll
                                          9,39MB        |      7,75MB        |    3,19MB    | QtGui4.dll
                                          1,15MB        |      0,77MB        |    0,28MB    | QTNetwork4.dll
                                          2,07MB        |      1,74MB        |    0,55MB    | QTScript4.dll
                                          0,20MB        |      0,20MB        |    0,08MB    | QTSql4.dll
                                          3,82MB        |      3,82MB        |    0,94MB    | QTXmlPatterns4.dll (wasn't compiled)
                                        

                                         21,98MB              18,55MB             6,51MB@
                                        

                                        These were the old results:

                                        @Uncompressed size | UPX -9 size | Name

                                          2,43MB          |    0,91MB    | QTCore4.dll
                                          2,92MB          |    0,86MB    | QTDeclarative4.dll
                                          9,39MB          |    3,69MB    | QtGui4.dll
                                          1,15MB          |    0,40MB    | QTNetwork4.dll
                                          2,07MB          |    0,65MB    | QTScript4.dll
                                          0,20MB          |    0,10MB    | QTSql4.dll
                                          3,82MB          |    0,94MB    | QTXmlPatterns4.dll
                                        

                                         21,98MB              7,55MB@
                                        
                                        1 Reply Last reply
                                        0
                                        • P Offline
                                          P Offline
                                          Peppy
                                          wrote on 18 May 2011, 11:13 last edited by
                                          #29

                                          From 22MB to 6,5MB is quite good ;-) ... Do you have any start-up "speed" test? Is it slower/faster ?

                                          1 Reply Last reply
                                          0

                                          19/36

                                          17 May 2011, 18:01

                                          • Login

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