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. Long start time for static linking application
Forum Updated to NodeBB v4.3 + New Features

Long start time for static linking application

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.9.0windows
5 Posts 3 Posters 2.5k 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
    goldstar2154
    wrote on last edited by
    #1

    Static version of application uses following qt - libs:

    #pragma comment(lib, "lib\\Qt5AccessibilitySupport.lib")
    #pragma comment(lib, "lib\\Qt5Core.lib")
    #pragma comment(lib, "lib\\Qt5EventDispatcherSupport.lib")
    #pragma comment(lib, "lib\\Qt5FontDatabaseSupport.lib")
    #pragma comment(lib, "lib\\Qt5Multimedia.lib")
    #pragma comment(lib, "lib\\Qt5MultimediaWidgets.lib")
    #pragma comment(lib, "lib\\Qt5Network.lib")
    #pragma comment(lib, "lib\\Qt5OpenGL.lib")
    #pragma comment(lib, "lib\\Qt5Test.lib")
    #pragma comment(lib, "lib\\Qt5ThemeSupport.lib")
    #pragma comment(lib, "lib\\Qt5Widgets.lib")
    #pragma comment(lib, "lib\\Qt5Xml.lib")
    #pragma comment(lib, "lib\\qtfreetype.lib")
    #pragma comment(lib, "lib\\qtharfbuzz.lib")
    #pragma comment(lib, "lib\\qtlibpng.lib")
    #pragma comment(lib, "lib\\qtmain.lib")
    #pragma comment(lib, "lib\\qtpcre2d.lib")
    #pragma comment(lib, "plugins\\mediaservice\\dsengine.lib")
    #pragma comment(lib, "plugins\\platforms\\qwindows.lib")
    

    This MS libs linked for qt proper working:

    #pragma comment(lib, "Ws2_32.lib")
    #pragma comment(lib, "opengl32.lib")
    #pragma comment(lib, "imm32.lib")
    #pragma comment(lib, "D3d9.lib")
    #pragma comment(lib, "UxTheme.lib")
    #pragma comment(lib, "Version.lib")
    #pragma comment(lib, "Dwmapi.lib")
    #pragma comment(lib, "Mf.lib")
    #pragma comment(lib, "Mfplat.lib")
    #pragma comment(lib, "Mfuuid.lib")
    #pragma comment(lib, "Dxva2.lib")
    #pragma comment(lib, "Evr.lib")
    #pragma comment(lib, "Winmm.lib")
    #pragma comment(lib, "Iphlpapi.lib")
    #pragma comment(lib, "Crypt32.lib")
    #pragma comment(lib, "Netapi32.lib")
    #pragma comment(lib, "Userenv.lib")
    

    Release and Debug version of application takes long time for first launch (~5-10 sec). Next launches take normal time (less than 0.5s). When application launching first time i see only loading icon and even debugger dont start.

    So problem is in windows application loader i guess. When i load application for first time windows loads all necessary dlls into memory and this take a time. When application closed this dlls still placed in memory (for some time) and next launch take less time, cause of all dlls are loaded.

    So is there solution to improve first launch time?

    Also this situation tested with dynamic version of qt. In this case app starts immediately, but we need single .exe (in business cases).

    Qt: 5.9.0 static + dynamic 32bit both
    OS: Win10 x64
    IDE/compiler: MSVC14 (static version of QT compiled with MSVC14 too)
    additional libs: botan, openssl, oculus, directX...(and 5 more private libs)

    1 Reply Last reply
    0
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @goldstar2154 said in Long start time for static linking application:

      So is there solution to improve first launch time?

      I think you don't want to hear it, but it is dynamic linking. For a static linked app, the whole data needs to be loaded into memory at once, while for the dynamic linked version the linker can load the libraries "on demand". And if the lib is already loaded, it is even faster.

      but we need single .exe (in business cases).

      Do you really need a single exe or do you just need the exe with all libraries so it runs without further intervention?

      Regards

      Qt has to stay free or it will die.

      G 1 Reply Last reply
      2
      • aha_1980A aha_1980

        @goldstar2154 said in Long start time for static linking application:

        So is there solution to improve first launch time?

        I think you don't want to hear it, but it is dynamic linking. For a static linked app, the whole data needs to be loaded into memory at once, while for the dynamic linked version the linker can load the libraries "on demand". And if the lib is already loaded, it is even faster.

        but we need single .exe (in business cases).

        Do you really need a single exe or do you just need the exe with all libraries so it runs without further intervention?

        Regards

        G Offline
        G Offline
        goldstar2154
        wrote on last edited by
        #3

        @aha_1980

        I mean only qt static linking, all windows dlls still dynamically loaded ofc
        Here is the list of dependencies, there are no qt dlls, only windows
        0_1537257030255_eff420d2-3f86-4970-a724-389c5ad1eac7-image.png

        Do you really need a single exe or do you just need the exe with all libraries so it runs without further intervention?

        We need single exe, because we using different versions of qt in different exe, and deployment of our program pack with dynamic qt linkage looks like dll hell...

        JonBJ 1 Reply Last reply
        0
        • G goldstar2154

          @aha_1980

          I mean only qt static linking, all windows dlls still dynamically loaded ofc
          Here is the list of dependencies, there are no qt dlls, only windows
          0_1537257030255_eff420d2-3f86-4970-a724-389c5ad1eac7-image.png

          Do you really need a single exe or do you just need the exe with all libraries so it runs without further intervention?

          We need single exe, because we using different versions of qt in different exe, and deployment of our program pack with dynamic qt linkage looks like dll hell...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @goldstar2154
          It is true that a dynamically linked executable will load faster than a statically linked because of the size/inability to use already-loaded modules. However on a "modern" PC the difference you report from 0.5 seconds to 5--10 seconds (10/20x) seems very high. 5 to 10 seconds to just load an application is a long time....

          • How big is the static executable, and how much free memory do you have available? If memory is short paging is a very expensive operation.

          • I wonder whether in addition to the time for load the static version is calling any "initial" code which the dynamic does not? I'm not sure whether dynamic loaded initialises at start-up or only on first call. But this would seem to be counteracted by your statement that after the first time it reverts to 0.5 seconds, and makes me think of memory shortage again....

          G 1 Reply Last reply
          2
          • JonBJ JonB

            @goldstar2154
            It is true that a dynamically linked executable will load faster than a statically linked because of the size/inability to use already-loaded modules. However on a "modern" PC the difference you report from 0.5 seconds to 5--10 seconds (10/20x) seems very high. 5 to 10 seconds to just load an application is a long time....

            • How big is the static executable, and how much free memory do you have available? If memory is short paging is a very expensive operation.

            • I wonder whether in addition to the time for load the static version is calling any "initial" code which the dynamic does not? I'm not sure whether dynamic loaded initialises at start-up or only on first call. But this would seem to be counteracted by your statement that after the first time it reverts to 0.5 seconds, and makes me think of memory shortage again....

            G Offline
            G Offline
            goldstar2154
            wrote on last edited by
            #5

            @JonB sorry for long reply
            debug size is 29.5M
            release size is 18.3M
            Free memory always a more than needed PC have 16Gb ram. Also i checked swap, swap is newer used for last days. So problem is not here.
            Next step i will check all dlls one by one in tes Win32 pure C application, maybe problem is here.

            no cpecific initial code ... but as u can see a lot of dependencies.. In linux exist LD_PRELOAD key but there is no solution for windows i found.

            Thanks for response, if i found any solution or reason i'll report it here.
            Cheers.

            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