Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt application size optimization
Forum Update on Monday, May 27th 2025

Qt application size optimization

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    RAJEESHR
    wrote on 15 Sept 2022, 05:11 last edited by RAJEESHR
    #1

    Hi All,

    we have a Qt application(UI written using widgets, not qml) which sizes more than 40mb. And also we have total ~1mb of image files which are now compiled into binary. In the hardware (specific h/w having limitation on memory) it took some time(~20sec) to load into the memory and showed up the first screen. Now we are trying to reduce the size of the application through maximum feasible ways. We thought of moving some part as a library which can be loaded separately on demand and other application optimization to reduce the boot time. Now my question to all Qt experts here is,
    From Qt perspective what all things I can try to reduce the Qt application?
    Is there any guideline/example link is there?
    -ltcg option is available with Qt5.7?

    Please help me. any help appreciated. Thanks in advance.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on 15 Sept 2022, 06:15 last edited by
      #2

      Platform? Compiler tools?
      Have you built a release executable?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RAJEESHR
        wrote on 19 Sept 2022, 02:12 last edited by
        #3

        OS: ubuntu
        compiling from Qt creator

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on 19 Sept 2022, 04:34 last edited by
          #4

          @RAJEESHR said in Qt application size optimization:

          From Qt perspective what all things I can try to reduce the Qt application?

          A single 40MB executable is a bit of a monster in the first place. It is going to take quite a while to load regardless of platform.

          Since we have no idea what the structure is, it hard to say where to cut.

          Make sure you are building a release executable. Debug executables are substantially larger.
          Since you are using GCC you can try the space optimisation compiler option (-Os) rather than the -O2 or -O3 default.
          Profile your code to see where it spend the most time during startup, then concentrate of those areas.

          It may be that the load time is actually a slow embedded processor loading and linking a huge file and libraries from a slow storage. Depending on which is the biggest bottleneck then an executable compression like UPX may help (you trade decompression time for file size).

          It may be that the load is constrained by memory and the machine is swapping. This will impact performance across the board.

          Is there any guideline/example link is there?

          No general guide is going to address your specific program on your target platform.

          -ltcg option is available with Qt5.7?

          No. Qt is a library and this is an option is for a compiler and/or linker.

          You are talking about a Microsoft compiler option so, no, it does not exist in your Ubuntu GCC tools. The rough equivalent would seem to be the -flto option. Please read the documentation because this option imposes a lot of conditions. I doubt this is going to massively improve much.

          1 Reply Last reply
          3
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 19 Sept 2022, 19:04 last edited by
            #5

            Hi,

            One thing you can also explore is the Qt feature system that allows you to disable quite a lot of features you don't use thus reducing the library and your application size.

            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
            1
            • K Offline
              K Offline
              kkoehne
              Moderators
              wrote on 20 Sept 2022, 07:15 last edited by
              #6

              You should also run strip on your binary.

              Director R&D, The Qt Company

              1 Reply Last reply
              2

              1/6

              15 Sept 2022, 05:11

              • Login

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