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 shared with static runtime on win
Forum Updated to NodeBB v4.3 + New Features

Qt shared with static runtime on win

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 2.0k Views 2 Watching
  • 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.
  • 3 Offline
    3 Offline
    3cxitalydev
    wrote on last edited by
    #1

    Hi,
    I need to create a win app for the Desktop that can be installed also by not admin users.
    But the vc_redist can be installed only by admins.

    So I need to compile qt and my app with these flags:
    -shared -static-runtime

    If I try to compile qt sources with this configuration I get an error because it says that -static-runtime flag can be used only in combination with -static.
    I think that it should technically possible to compile qt sources producing dlls (shared) but using the static runtime (-static-runtime or /MT), isn't it?

    Can you help me on this, please?

    Thank you in advance

    Regards,

    Emanuele

    JKSHJ 1 Reply Last reply
    0
    • B Offline
      B Offline
      bludger
      wrote on last edited by
      #2

      Compiling Qt statically implies that you either have a commercial Qt license (if you want to keep your application source closed), otherwise you'll need to license your application as GPL and distribute its source code.

      Why not simply include the redist dlls in your installer which put them in the same directory as your application? That way you can use Qt as LPGL and keep your application' code closed.

      SGaistS 1 Reply Last reply
      0
      • 3 Offline
        3 Offline
        3cxitalydev
        wrote on last edited by
        #3

        Hi,
        thank you for your answer.
        I have to understand exactly which dlls are installed by the redist.
        Do you have a suggestion on how to check exactly all the dlls installed by redist and where?
        Also I am not sure if the redist installer does some other useful things like writing the registry, ...

        For what I understand, I think that recompiling qt dlls with runtime-static doesn't require a commercial license because my application will continue to use qt dlls as before (lgpl).
        Maybe I am wrong on this, so it could be good if someone could explain exactly on this aspect of qt.

        My intention is not to compile qt with the -static flag, but only with -static-runtime only.
        But the script for compiling qt doesn't allow -shared -static-runtime flags at the same time.
        And this shouldn't have a technical reason because producing dlls that don't need the redist should be possible without problems.

        Regards,

        Emanuele

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bludger
          wrote on last edited by bludger
          #4

          It seems not to be possible to use -shared and -static-runtime together.

          It is actually quite simple. You probably have the windeployqt tool witihin the bin directory of your current Qt installation. This tool does exactly what you want. Simply do this:

          c:\path\to\qt\bin\windeployqt.exe --compiler-runtime c:\path\to\my\application.exe
          

          It will gather all required dlls by your application including the runtime ones.

          Alternatively:

          Usually the Visual Studio redist will install a couple of DLL's. Using dependency walker it is quite easy to figure out which DLLs are required by your application. It may even be easier for you, depending on your Visual Studio version you can have a look in the following folder (14.0 = Visual Studio 2015, change accordingly to your version):

          C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist
          

          You'll find a couple of folders which are of interest. If you're building a 32 bit application you'll need to go to the following folder:

          C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
          

          Within that folder you find the DLLs as distributed by the redist package. Just copy these and put them near your executable. Furthermore you may need an additional DLL (ucrtbased.dll). This can be found in the Windows SDK directory using the same directory structure as for Visual Studio.

          3 1 Reply Last reply
          0
          • B bludger

            It seems not to be possible to use -shared and -static-runtime together.

            It is actually quite simple. You probably have the windeployqt tool witihin the bin directory of your current Qt installation. This tool does exactly what you want. Simply do this:

            c:\path\to\qt\bin\windeployqt.exe --compiler-runtime c:\path\to\my\application.exe
            

            It will gather all required dlls by your application including the runtime ones.

            Alternatively:

            Usually the Visual Studio redist will install a couple of DLL's. Using dependency walker it is quite easy to figure out which DLLs are required by your application. It may even be easier for you, depending on your Visual Studio version you can have a look in the following folder (14.0 = Visual Studio 2015, change accordingly to your version):

            C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist
            

            You'll find a couple of folders which are of interest. If you're building a 32 bit application you'll need to go to the following folder:

            C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
            

            Within that folder you find the DLLs as distributed by the redist package. Just copy these and put them near your executable. Furthermore you may need an additional DLL (ucrtbased.dll). This can be found in the Windows SDK directory using the same directory structure as for Visual Studio.

            3 Offline
            3 Offline
            3cxitalydev
            wrote on last edited by
            #5

            @bludger said in Qt shared with static runtime on win:

            It seems not to be possible to use -shared and -static-runtime together.

            It is actually quite simple. You probably have the windeployqt tool witihin the bin directory of your current Qt installation. This tool does exactly what you want. Simply do this:

            c:\path\to\qt\bin\windeployqt.exe --compiler-runtime c:\path\to\my\application.exe
            

            It will gather all required dlls by your application including the runtime ones.

            I already tried this, but it simply copy the vc_redist.x64.exe setup into destination folder, but then you need to be admin to install it, and in my case the app must be installed also if you are not admin

            Alternatively:

            Usually the Visual Studio redist will install a couple of DLL's. Using dependency walker it is quite easy to figure out which DLLs are required by your application.

            Dependency Walker get stuck analizing my simple application. And with this solution maybe I have to analyze also all qt dlls to be sure about their deps.

            It may even be easier for you, depending on your Visual Studio version you can have a look in the following folder (14.0 = Visual Studio 2015, change accordingly to your version):

            C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist
            

            You'll find a couple of folders which are of interest. If you're building a 32 bit application you'll need to go to the following folder:

            C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
            

            Within that folder you find the DLLs as distributed by the redist package. Just copy these and put them near your executable. Furthermore you may need an additional DLL (ucrtbased.dll). This can be found in the Windows SDK directory using the same directory structure as for Visual Studio.

            This last solution could be interesting. I gonna try to copy the dlls contained in the following folder:
            C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.16.27012\x64\Microsoft.VC141.CRT
            into my app folder and see if my app complains for missing dlls.

            Thank you for now for your help, I hope it works

            1 Reply Last reply
            0
            • B bludger

              Compiling Qt statically implies that you either have a commercial Qt license (if you want to keep your application source closed), otherwise you'll need to license your application as GPL and distribute its source code.

              Why not simply include the redist dlls in your installer which put them in the same directory as your application? That way you can use Qt as LPGL and keep your application' code closed.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @bludger said in Qt shared with static runtime on win:

              Compiling Qt statically implies that you either have a commercial Qt license (if you want to keep your application source closed), otherwise you'll need to license your application as GPL and distribute its source code.

              That's wrong. You are allowed to do that but it's pretty hard to comply with the LGPL requirements when using a static build. That's nothing specific to Qt though, any LGPL library will generate the same troubles.

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

              3 1 Reply Last reply
              0
              • SGaistS SGaist

                @bludger said in Qt shared with static runtime on win:

                Compiling Qt statically implies that you either have a commercial Qt license (if you want to keep your application source closed), otherwise you'll need to license your application as GPL and distribute its source code.

                That's wrong. You are allowed to do that but it's pretty hard to comply with the LGPL requirements when using a static build. That's nothing specific to Qt though, any LGPL library will generate the same troubles.

                3 Offline
                3 Offline
                3cxitalydev
                wrote on last edited by
                #7

                @SGaist
                But to don't have any problem at all should be nice to have -shared -static-runtime flags available at the same time.

                1 Reply Last reply
                0
                • 3 3cxitalydev

                  Hi,
                  I need to create a win app for the Desktop that can be installed also by not admin users.
                  But the vc_redist can be installed only by admins.

                  So I need to compile qt and my app with these flags:
                  -shared -static-runtime

                  If I try to compile qt sources with this configuration I get an error because it says that -static-runtime flag can be used only in combination with -static.
                  I think that it should technically possible to compile qt sources producing dlls (shared) but using the static runtime (-static-runtime or /MT), isn't it?

                  Can you help me on this, please?

                  Thank you in advance

                  Regards,

                  Emanuele

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

                  @3cxitalydev said in Qt shared with static runtime on win:

                  I need to create a win app for the Desktop that can be installed also by not admin users.
                  But the vc_redist can be installed only by admins.

                  One option is to use the MinGW compiler. Then, you can distribute the MinGW DLLs directly with your app so the user doesn't need to install vc_redist.

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

                  hskoglundH 1 Reply Last reply
                  0
                  • JKSHJ JKSH

                    @3cxitalydev said in Qt shared with static runtime on win:

                    I need to create a win app for the Desktop that can be installed also by not admin users.
                    But the vc_redist can be installed only by admins.

                    One option is to use the MinGW compiler. Then, you can distribute the MinGW DLLs directly with your app so the user doesn't need to install vc_redist.

                    hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by
                    #9

                    @JKSH said

                    One option is to use the MinGW compiler. Then, you can distribute the MinGW DLLs directly with your app so the user doesn't need to install vc_redist.

                    This is why I have switched from Visual Studio to MinGW (also for example Qt's installation program has switched).

                    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