Qt combined with Visual Studio compilation, packaging and publishing

Posted by bri0987 on Thu, 17 Feb 2022 16:41:32 +0100

1,qt

Find qt dynamic link library used in the project;

The steps are as follows

① Open the windeployqt tool used by the project (qt's own tool);

② Enter the directory where the folder is located; Using the cd command

③ Use the command: windeployqt name Exe (execute the command in the directory where the target folder is located)

 

However, because my QT uses MSVC compiler, I will use some VC libraries. I will be prompted when using QT command line

warning: Cannot find Visual Studio installation directory,VCINSTALLDIR is not set.

Solution 1

win+R, enter windeployqt.qt in QT installation directory Exe path, then a space, plus the path of the project Release.
Mine is: C: \ QT \ Qt5 13.1\5.13.1\msvc2015_ 64\bin\windeployqt. exe D:\GIICS\qtReleaseDemo\x64\Release\qtReleaseDemo. Exe for reference.

Then there will be this warning, which is difficult to be found in the middle. Pay attention!

Found msvcp140d DLL (I am VS2015, so it is 140), copy its path and add it to the environment variable. My path is C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\debug_nonredist\x64\Microsoft.VC140.DebugCRT\msvcp140d.dll. When adding environment variables, just go to VC. Don't use the latter.

 

 

Close cmd and reopen it (be sure to close the previously opened one first and then reopen it). Enter the path in step 3, C: \ QT \ Qt5 13.1\5.13.1\msvc2015_ 64\bin\windeployqt. exe D:\GIICS\qtReleaseDemo\x64\Release\qtReleaseDemo. Exe, just enter.

You can see that there are many more DLLs and vcredist of QT in the Release folder_ x64. Exe will do. Putting this folder on a brand new computer can also run, but you have to install vcredist in the figure on the computer first exe.     

 

Method 2

  1. First, change the configuration to Release.

  2. Next, rebuild the project.

  3. Then you can find the generated exe file from the project directory / x64/Release /.

  4. If you want to run the exe file, you need to put each dll file in the same folder as it.

    Here we mainly need some dll files of qt, which can be found in the qt installation directory msvc2017_ Found in the 64 / bin folder.

You should all know how to use windeployqt,

Copy the release version exe to a separate directory;

4.2 open MSVC 2017 console under QT and switch to the directory where exe was just located;

4.3 then use the windeployqt tool command provided by Qt. Its syntax format is:

windeployqt executable name

4.4 you can see that the windeployqt tool has copied the qt environment that the program depends on to the current directory.

There is also the installation path to VS

C:\ProgramFiles(x86)\MicrosoftVisualStudio14.0\Common7\IDE\RemoteDebugger\x64
If you are developed by x64, choose x64, or choose x86

Copy out the following runtime and put it under the exe path, otherwise it will be extremely embarrassing to encounter runtime errors!

api-ms-win-core-console-l1-1-0.dll
api-ms-win-core-datetime-l1-1-0.dll
api-ms-win-core-debug-l1-1-0.dll
api-ms-win-core-errorhandling-l1-1-0.dll
api-ms-win-core-file-l1-1-0.dll
api-ms-win-core-file-l1-2-0.dll
api-ms-win-core-file-l2-1-0.dll
api-ms-win-core-handle-l1-1-0.dll
api-ms-win-core-heap-l1-1-0.dll
api-ms-win-core-interlocked-l1-1-0.dll
api-ms-win-core-libraryloader-l1-1-0.dll
api-ms-win-core-localization-l1-2-0.dll
api-ms-win-core-memory-l1-1-0.dll
api-ms-win-core-namedpipe-l1-1-0.dll
api-ms-win-core-processenvironment-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-1.dll
api-ms-win-core-profile-l1-1-0.dll
api-ms-win-core-rtlsupport-l1-1-0.dll
api-ms-win-core-string-l1-1-0.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-core-synch-l1-2-0.dll
api-ms-win-core-sysinfo-l1-1-0.dll
api-ms-win-core-timezone-l1-1-0.dll
api-ms-win-core-util-l1-1-0.dll
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-multibyte-l1-1-0.dll
api-ms-win-crt-private-l1-1-0.dll
api-ms-win-crt-process-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
concrt140.dll
msvcp140.dll
ucrtbase.dll
vcruntime140.dll

In case of 0xc00000007b, you should not put the above libraries completely.

Note concrt140 dll
msvcp140.dll
vcruntime140.dll (I'm VS2015, so it's 140)

Topics: Qt IDE Visual Studio