Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Reduce Qt libraries size
QtWS25 Last Chance

Reduce Qt libraries size

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
sizeembeddedreduce library
9 Posts 4 Posters 6.9k 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.
  • I Offline
    I Offline
    IL
    wrote on 17 Aug 2016, 07:00 last edited by
    #1

    Hi guys,
    Is there any suitable way to reduce Qt shared objects files size using QT tool or using any other external tool, this is sure after removing all unnecessary features in configuration and striping of-course.
    I am asking that because we are limited in our disk space.
    I already search for external tools and found mklibs, this tool cut-down shared libraries to contain only the routines required by a particular set of executable, but this is seem to be fit for debian systems.

    Please advice.
    IL

    R 1 Reply Last reply 20 Aug 2016, 13:26
    1
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 17 Aug 2016, 21:59 last edited by
      #2

      Hi,

      Are you looking for a way to build Qt with a reduced feature set to match only what you need ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I IL
        17 Aug 2016, 07:00

        Hi guys,
        Is there any suitable way to reduce Qt shared objects files size using QT tool or using any other external tool, this is sure after removing all unnecessary features in configuration and striping of-course.
        I am asking that because we are limited in our disk space.
        I already search for external tools and found mklibs, this tool cut-down shared libraries to contain only the routines required by a particular set of executable, but this is seem to be fit for debian systems.

        Please advice.
        IL

        R Offline
        R Offline
        Red Baron
        wrote on 20 Aug 2016, 13:26 last edited by
        #3

        @IL I'm not sure about the flags that QMAKE uses when calling gcc in a release build but my guess would be O2. You can check the generated Makefile for the specific flags. Then you can do some digging in the documentation of gcc and see what else you can add to make the sos smaller. Usually optimization level Os does a pretty good job. I have a shared library which, when built without this level of optimization, is approx. 3MB. After setting the gcc to use Os it shrunk down to 51KB. Use QMAKE_CXXFLAGS += ... inside your project file to specify the flags you want to pass to gcc and test various configurations. In addition to that @SGaist gives also a great suggestion - reducing the feature set of Qt. If you know for sure which components you need then you can dispose of the rest. Some of the components (such as charts and data visualization) are actually considered extra (mostly due to licensing issues would be my guess) and when building Qt you have to explicitly configure your build to add those.

        Please provide more information on the device, your use case scenario and the current configuration you have. More details on the application you are building would also help us provide you with more advice.

        I 1 Reply Last reply 28 Aug 2016, 14:12
        0
        • R Red Baron
          20 Aug 2016, 13:26

          @IL I'm not sure about the flags that QMAKE uses when calling gcc in a release build but my guess would be O2. You can check the generated Makefile for the specific flags. Then you can do some digging in the documentation of gcc and see what else you can add to make the sos smaller. Usually optimization level Os does a pretty good job. I have a shared library which, when built without this level of optimization, is approx. 3MB. After setting the gcc to use Os it shrunk down to 51KB. Use QMAKE_CXXFLAGS += ... inside your project file to specify the flags you want to pass to gcc and test various configurations. In addition to that @SGaist gives also a great suggestion - reducing the feature set of Qt. If you know for sure which components you need then you can dispose of the rest. Some of the components (such as charts and data visualization) are actually considered extra (mostly due to licensing issues would be my guess) and when building Qt you have to explicitly configure your build to add those.

          Please provide more information on the device, your use case scenario and the current configuration you have. More details on the application you are building would also help us provide you with more advice.

          I Offline
          I Offline
          IL
          wrote on 28 Aug 2016, 14:12 last edited by
          #4

          @Red-Baron, I will take your advice for checking gcc optimization but truly I do not find a way to do so.
          Basically I am running the configuration command and then the qt-make

          ./configure -v -device arm-none-linux-gnueabi -device-option CROSS_COMPILE=$CROSS_COMPILE -release -confirm-license -opensource -nomake examples -qt-zlib -no-pch -no-largefile -no-c++11 -no-cups -lrt  -linuxfb -no-xcb -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-accessibility -no-openssl -no-gtkstyle -xplatform devices/arm-none-linux-gnueabi --prefix=/opt/HH/CodeSourceryArm2009q1203/arm-none-linux-gnueabi/libc/usr -no-qml-debug -no-avx -no-avx2 -no-mips_dsp -no-mips_dspr2 -no-mtdev -no-libproxy -no-xkbcommon-evdev -no-xinput2 -no-xcb-xlib -no-nis -no-iconv -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus -no-use-gold-linker -no-separate-debug-info -no-directfb -no-kms -no-gcc-sysroot -no-libinput -nomake tests -gstreamer 1.0 -force-pkg-config -no-audio-backend -no-freetype -no-harfbuzz -no-qpa
          
          make module-qtbase
          

          Where should I add the O2 or OS flags?
          As I mention above regarding @SGaist recommendation about remove unnecessary features, I think I already did what I can.

          Best regards,
          IL

          R 1 Reply Last reply 29 Aug 2016, 09:41
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 28 Aug 2016, 15:13 last edited by
            #5

            Then you should take a look at the Qt Lite project. Short version: It's a big refactoring of the current "feature" system that allows to build Qt with less features. The Qt Lite project will offer an easier way to get that.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            I 1 Reply Last reply 29 Aug 2016, 06:59
            1
            • S SGaist
              28 Aug 2016, 15:13

              Then you should take a look at the Qt Lite project. Short version: It's a big refactoring of the current "feature" system that allows to build Qt with less features. The Qt Lite project will offer an easier way to get that.

              I Offline
              I Offline
              IL
              wrote on 29 Aug 2016, 06:59 last edited by
              #6

              @SGaist I will check that.
              Best regards,
              IL

              1 Reply Last reply
              0
              • I IL
                28 Aug 2016, 14:12

                @Red-Baron, I will take your advice for checking gcc optimization but truly I do not find a way to do so.
                Basically I am running the configuration command and then the qt-make

                ./configure -v -device arm-none-linux-gnueabi -device-option CROSS_COMPILE=$CROSS_COMPILE -release -confirm-license -opensource -nomake examples -qt-zlib -no-pch -no-largefile -no-c++11 -no-cups -lrt  -linuxfb -no-xcb -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-accessibility -no-openssl -no-gtkstyle -xplatform devices/arm-none-linux-gnueabi --prefix=/opt/HH/CodeSourceryArm2009q1203/arm-none-linux-gnueabi/libc/usr -no-qml-debug -no-avx -no-avx2 -no-mips_dsp -no-mips_dspr2 -no-mtdev -no-libproxy -no-xkbcommon-evdev -no-xinput2 -no-xcb-xlib -no-nis -no-iconv -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus -no-use-gold-linker -no-separate-debug-info -no-directfb -no-kms -no-gcc-sysroot -no-libinput -nomake tests -gstreamer 1.0 -force-pkg-config -no-audio-backend -no-freetype -no-harfbuzz -no-qpa
                
                make module-qtbase
                

                Where should I add the O2 or OS flags?
                As I mention above regarding @SGaist recommendation about remove unnecessary features, I think I already did what I can.

                Best regards,
                IL

                R Offline
                R Offline
                Red Baron
                wrote on 29 Aug 2016, 09:41 last edited by
                #7

                @IL QMAKE_CXXFLAGS (and its derivatives) is something that you put inside your project file:

                blahblah.pro

                  TARGET = BlahBlah
                  # ...
                  QMAKE_CXXFLAGS += -Os
                  # ...
                

                For example I have pri file with a bunch of stuff among which I have

                QMAKE_CXXFLAGS_RELEASE += -Os
                QMAKE_CXXFLAGS_DEBUG += -O0
                

                which basically means that of debug build -O0 will be used (I actually do believe that this is the default behavour in Qt) while -Os will be for the release buid.

                If you are more comfortable directly working with the Makefile you can open the generated by qmake Makefile and set the flag directly there however I would advice doing that just for a small check since whenever Rebuild is executed in your Qt Creator the Makefile will be replaced with a fresh one and your changes will be gone. That is why using the project file for setting these things is the right way to go.

                S 1 Reply Last reply 1 Sept 2016, 11:14
                0
                • R Red Baron
                  29 Aug 2016, 09:41

                  @IL QMAKE_CXXFLAGS (and its derivatives) is something that you put inside your project file:

                  blahblah.pro

                    TARGET = BlahBlah
                    # ...
                    QMAKE_CXXFLAGS += -Os
                    # ...
                  

                  For example I have pri file with a bunch of stuff among which I have

                  QMAKE_CXXFLAGS_RELEASE += -Os
                  QMAKE_CXXFLAGS_DEBUG += -O0
                  

                  which basically means that of debug build -O0 will be used (I actually do believe that this is the default behavour in Qt) while -Os will be for the release buid.

                  If you are more comfortable directly working with the Makefile you can open the generated by qmake Makefile and set the flag directly there however I would advice doing that just for a small check since whenever Rebuild is executed in your Qt Creator the Makefile will be replaced with a fresh one and your changes will be gone. That is why using the project file for setting these things is the right way to go.

                  S Offline
                  S Offline
                  Schluchti
                  wrote on 1 Sept 2016, 11:14 last edited by
                  #8

                  @Red-Baron That's a very interesting approach. Have you encountered any problems when using that optimization level together with the Qt framework? I am always afraid to run into some strange optimization errors. (when the debug version behaves slightly different to the release version) I know that those things occur very rarely, but when they occur they are pretty hard to detect.

                  Have a nice day,
                  Bernhard

                  Want to read more about Qt?

                  https://gympulsr.com/blog/qt/

                  Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                  R 1 Reply Last reply 1 Sept 2016, 14:20
                  0
                  • S Schluchti
                    1 Sept 2016, 11:14

                    @Red-Baron That's a very interesting approach. Have you encountered any problems when using that optimization level together with the Qt framework? I am always afraid to run into some strange optimization errors. (when the debug version behaves slightly different to the release version) I know that those things occur very rarely, but when they occur they are pretty hard to detect.

                    Have a nice day,
                    Bernhard

                    R Offline
                    R Offline
                    Red Baron
                    wrote on 1 Sept 2016, 14:20 last edited by
                    #9

                    @Schluchti I don't recall ever having an issue with the -Os flag in specific but then again it really depends on what you are doing and how you are coding it. :P

                    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