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. Executable on Linux always so large, why?
QtWS25 Last Chance

Executable on Linux always so large, why?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 786 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.
  • H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #1

    When creating an installer on linux for a Qt app, the installer executable created are always big (around 58MiB) don't matter how small is the app created and that because of the .so that goes together with the executable.

    I am wondering if there's a way to avoid this or always when creating an installer for a Qt app on linux the resulting installer executable will be that big.

    JKSHJ 1 Reply Last reply
    0
    • H hbatalha

      When creating an installer on linux for a Qt app, the installer executable created are always big (around 58MiB) don't matter how small is the app created and that because of the .so that goes together with the executable.

      I am wondering if there's a way to avoid this or always when creating an installer for a Qt app on linux the resulting installer executable will be that big.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

      @hbatalha said in Executable on Linux always so large, why?:

      When creating an installer on linux for a Qt app, the installer executable created are always big (around 58MiB)

      You didn't tell us which installer software you used.

      Some possibilities are:

      • (e.g. The Qt Installer Framework) The installer executable depends on some libraries, and it uses static linking instead of dynamic linking. Static linking embeds the libraries into the executable itself; this means that the user can run the executable even if the libraries are not found on the PC, but of course embedding libraries will dramatically increase executable size.

      • (e.g. AppImage, Snap, or Flatpak) The installer is actually a self-contained bundle. It contains your app plus all the libraries that your app depends on.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      H 1 Reply Last reply
      1
      • JKSHJ JKSH

        @hbatalha said in Executable on Linux always so large, why?:

        When creating an installer on linux for a Qt app, the installer executable created are always big (around 58MiB)

        You didn't tell us which installer software you used.

        Some possibilities are:

        • (e.g. The Qt Installer Framework) The installer executable depends on some libraries, and it uses static linking instead of dynamic linking. Static linking embeds the libraries into the executable itself; this means that the user can run the executable even if the libraries are not found on the PC, but of course embedding libraries will dramatically increase executable size.

        • (e.g. AppImage, Snap, or Flatpak) The installer is actually a self-contained bundle. It contains your app plus all the libraries that your app depends on.

        H Offline
        H Offline
        hbatalha
        wrote on last edited by hbatalha
        #3

        @JKSH said in Executable on Linux always so large, why?:

        You didn't tell us which installer software you used.

        I used Qt Installer Framework, binarycreator.

        I read somewhere that to build static apps with Qt you will have to build Qt statically and then build first/

        JKSHJ 1 Reply Last reply
        0
        • H hbatalha

          @JKSH said in Executable on Linux always so large, why?:

          You didn't tell us which installer software you used.

          I used Qt Installer Framework, binarycreator.

          I read somewhere that to build static apps with Qt you will have to build Qt statically and then build first/

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @hbatalha said in Executable on Linux always so large, why?:

          I read somewhere that to build static apps with Qt you will have to build Qt statically and then build first

          The Qt Installer Frame uses static linking for the installer executable.

          Your app executable does not need to use static linking.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          H 1 Reply Last reply
          1
          • JKSHJ JKSH

            @hbatalha said in Executable on Linux always so large, why?:

            I read somewhere that to build static apps with Qt you will have to build Qt statically and then build first

            The Qt Installer Frame uses static linking for the installer executable.

            Your app executable does not need to use static linking.

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #5

            @JKSH Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

            JKSHJ C 2 Replies Last reply
            0
            • H hbatalha

              @JKSH Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @hbatalha said in Executable on Linux always so large, why?:

              Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

              This issue has nothing to do with the installer; binarycreator simply copies the files that you tell it to copy; it doesn't link your libraries to your app.

              Please open a new thread to discuss static linking your application.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2
              • H hbatalha

                @JKSH Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

                C Offline
                C Offline
                ChrisW67
                wrote on last edited by
                #7

                @hbatalha said in Executable on Linux always so large, why?:

                Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

                If you have a lot of shared libraries (the .so files) for Qt libraries then you probably have a dynamically linked Qt application.

                If your application was statically linked then the application executable would be a single, large binary that contained the relevant parts of the Qt libraries internally. There may be a couple of associated 3rd party shared libraries (perhaps for ICU). You have to go out of your way to make a Qt library set that supports being statically linked: it's not something you do accidentally.

                As for the size problem:

                • Ensure you are shipping release libraries that have been stripped with your release build application. Debugging information can be bulky.
                • Ensure you are not shipping Qt libraries your application is not using. E.g. Qt5 Qml is not needed if you are not using QML, and Qt5 WebEngine is huge.
                • If you know the target environment then you might be able to omit libraries like ICU because a compatible version is already present.
                • You may be able to use something like UPX to compress the executable
                H 1 Reply Last reply
                1
                • C ChrisW67

                  @hbatalha said in Executable on Linux always so large, why?:

                  Then I am not configuring it right because mine is static, it install the program into a folder containing the executable together with all the .so files

                  If you have a lot of shared libraries (the .so files) for Qt libraries then you probably have a dynamically linked Qt application.

                  If your application was statically linked then the application executable would be a single, large binary that contained the relevant parts of the Qt libraries internally. There may be a couple of associated 3rd party shared libraries (perhaps for ICU). You have to go out of your way to make a Qt library set that supports being statically linked: it's not something you do accidentally.

                  As for the size problem:

                  • Ensure you are shipping release libraries that have been stripped with your release build application. Debugging information can be bulky.
                  • Ensure you are not shipping Qt libraries your application is not using. E.g. Qt5 Qml is not needed if you are not using QML, and Qt5 WebEngine is huge.
                  • If you know the target environment then you might be able to omit libraries like ICU because a compatible version is already present.
                  • You may be able to use something like UPX to compress the executable
                  H Offline
                  H Offline
                  hbatalha
                  wrote on last edited by hbatalha
                  #8

                  @ChrisW67

                  You have to go out of your way to make a Qt library set that supports being statically linked: it's not something you do accidentally.

                  Is any there any change that the resulting executable will be smaller smaller.

                  Ensure you are not shipping Qt libraries your application is not using. E.g. Qt5 Qml is not needed if you are not using QML, and Qt5 WebEngine is huge.

                  The ones that are pretty huge(25MiB each) are libicudata.so.56.1 and libicudata.so.56.

                  You may be able to use something like UPX to compress the executable

                  Thanks, that helped a lot

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by ChrisW67
                    #9

                    @hbatalha said in Executable on Linux always so large, why?:

                    libicudata.so.56.1 and libicudata.so.56.

                    These are the same file; libicudata.so and libicudata.so.56 are links to the actual file libicudata.so.56.1.
                    You only need to ship one

                    $ ls -l libicudat*
                    lrwxrwxrwx 1 chrisw chrisw       18 Jun  8  2020 libicudata.so -> libicudata.so.56.1
                    lrwxrwxrwx 1 chrisw chrisw       18 Jun  8  2020 libicudata.so.56 -> libicudata.so.56.1
                    -rwxr-xr-x 1 chrisw chrisw 25048256 Sep 26  2016 libicudata.so.56.1
                    

                    This mechanism is used to cater for a program that can function with any ICU (links to libicudata.so), needs any ICU at version 56 (links to libicudata.so.56), or specifically needs 56.1. Run ldd against your compiled application to see what it links to (probably libicudata.so.56).

                    H 1 Reply Last reply
                    3
                    • C ChrisW67

                      @hbatalha said in Executable on Linux always so large, why?:

                      libicudata.so.56.1 and libicudata.so.56.

                      These are the same file; libicudata.so and libicudata.so.56 are links to the actual file libicudata.so.56.1.
                      You only need to ship one

                      $ ls -l libicudat*
                      lrwxrwxrwx 1 chrisw chrisw       18 Jun  8  2020 libicudata.so -> libicudata.so.56.1
                      lrwxrwxrwx 1 chrisw chrisw       18 Jun  8  2020 libicudata.so.56 -> libicudata.so.56.1
                      -rwxr-xr-x 1 chrisw chrisw 25048256 Sep 26  2016 libicudata.so.56.1
                      

                      This mechanism is used to cater for a program that can function with any ICU (links to libicudata.so), needs any ICU at version 56 (links to libicudata.so.56), or specifically needs 56.1. Run ldd against your compiled application to see what it links to (probably libicudata.so.56).

                      H Offline
                      H Offline
                      hbatalha
                      wrote on last edited by
                      #10

                      @ChrisW67

                      You only need to ship one

                      Yeah you're right.

                      Thank you for all the help!

                      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