Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56566

windeployqt fails for MSVC2015

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.7.0
    • None

    Description

      As reported in https://bugreports.qt.io/browse/QTBUG-48659 and closed with an invitation to re-open, windeployqt creates directories that will not run, unless vcredist_x86 or vcredist_x64 for VS 2015 is already installed. Yet, the help page for it says:

      "The Windows deployment tool is designed to automate the process of creating a deployable folder containing the dependencies (libraries, QML imports, plugins, and translations) that are required to run the application from that folder. It creates a sandbox for Windows Runtime or an installation tree for Windows desktop applications, which can be easily bundled into an installation package."

      If it lacks the runtime files, it has not created a "folder containing the dependencies ... that are required to run the application from that folder." While it may run on the DEVELOPER's computer, already having VS2015 installed, the point of deployment is for it to run on OTHER computers, is it not? I have a desktop app made with Qt Creator and Qt 5.7.0, and I am trying to deploy to all Windows OS's from XP to Win 10. While vcredist will install on OS's as old as XP (if not older), not a single runtime file is included in the resultant directory made by windeployqt. Fortunately, I just happen to have the solution. Ideally, windeployqt might give the developer a choice to include the redistributable files vcredist_x86 or vcredist_x64 as needed (as they are included with a VS 2015 install with SDK, i.e. a custom install of VS 2015 with one of the Windows 10 SDK's under Windows and Web Development checked), use the app local files described below, or neither. If this option is chosen, people would also want it to be able to be selected from a command line switch.

      While installing app local used to not be supported for Universal Runtime, this has changed as pointed out by this StackOverflow ?:

      http://stackoverflow.com/questions/32601941/msvc-2015-universal-crt-for-app-local-deployment

      It points out to this MSDN blog article (where we all think to look for info to deploy ... NOT!):

      https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/

      It claims that the files needed can be found here:

      C:\Program Files (x86)\Windows Kits\10\Redist\ucrt

      This has two mistakes: 1) It is not always installed there, and 2) it was still not complete enough to deploy my app.

      This StackOverflow ? almost gets it right (i.e. the part written before I added my answer):

      http://stackoverflow.com/questions/31811597/visual-c-2015-redistributable-dlls-for-app-local-deployment?rq=1

      It says you will need C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT. Again, it might be installed elsewhere; and I needed an additional file yet.

      Based on these clues, I found the files I needed to make it run on XP. For those interested, here are the steps to make this happen. This is nice if you want to make a portable app, or one which can be installed by users without admin permission.

      To make my app run on XP without the vcredist_x86 setup, I needed to:

      1. Add "QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01", and on a separate line, "DEFINES += _WIN32_WINNT=0x501" to yer .pro file.
      2. Run windeployqt to generate the directory with the program and its Qt dependencies only.
      3. Copy the files from "C:\Program Files\Windows Kits\10\Redist\ucrt\DLLs\x86" or "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86" into the directory made by windeployqt (or copy them from the x64 directory if it's a 64-bit app).
      4. Copy msvcp140.dll and vcruntime140.dll from:
      <Visual Studio 2015 Install Directory>\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT (or copy them from the x64 directory if it's a 64-bit app).

      These were both necessary and sufficient to get my app to run under XP. Note that steps 2 & 3 are necessary to get the app to run under any OS that does NOT have the VS 2015 redistributable installed. This also works for OS's as recent as Win10. I have also tried a number of alternate strategies, such as running Dependency Walker to determine needed DLL's, and other groups of universal runtime files, such as a list of files at a Qt forum that someone else said worked for them, the "WindowsUCRT.zip" file, and bunches of files from my C:\Windows\System32 directory. Only the files in the above numbered list from the blog post produced a running app for me. The blog post claims these files will enable it to run on any OS.

      You may now bow down and thank me for my 3£33t research into arcane knowledge about how to get VS 2015 apps to run on older M$ OS's; and how to make windeployqt work as advertised (as opposed to having it leave out crucial runtime files and marking the issue closed without doing anything about it).

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-56566
          # Subject Branch Project Status CR V

          Activity

            People

              kleint Friedemann Kleint
              codelurker Code Lurker
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes