I am building an application using Qt C++ and I want it to run on windows computers without having to install VC Redistributables. Apparently when user tries to run the application an error pops that says that VCRUNTIME140.dll is missing.
-
3VC Redistributables don't concern Qt applications only but rather any compiled C++ application (on Windows). I believe there is the necessity anyway either to request the user to pre-install the redists or to include them in the installer for the case that they are missing. (Of course, we prefer the latter as this is more convenient for the user.) – Scheff's Cat Nov 19 '21 at 13:55
-
1FYI: [MS: Choosing a Deployment Method](https://learn.microsoft.com/en-us/cpp/windows/choosing-a-deployment-method?view=msvc-170) Maybe, I underestimated the fact that this might be an MSVC specific issue. (We never used anything else on Windows.) Not sure, whether MinGW could be a way out. However, I'm not sure as well whether it's worth the trouble. Compiling in MinGW can provide issues as well... – Scheff's Cat Nov 19 '21 at 13:59
-
1I just package the redistributable in the NSIS based installer that I have CMake generate for my Qt based applications. In most cases the redistributable does not need to be installed but its there when needed. – drescherjm Nov 19 '21 at 14:03
-
2@Scheff'sCat This is absolutely not true for every C++ application compiled on/for Windows. For example if you compile with GCC instead of MSVC there is no dependency on a VC Redistributable. – Eric Nov 19 '21 at 15:27
-
1@Eric This is what I addressed in my [2nd comment](https://stackoverflow.com/questions/70035885/how-to-build-a-qt-c-application-that-doesnt-need-vc-redistributables-on-a-pc?noredirect=1#comment123804433_70035885) when I mentioned MinGW. I must admit that I have very less experience with MinGW. ;-) – Scheff's Cat Nov 19 '21 at 15:33
2 Answers
Build both Qt and your application using compiler option /MT
?
https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170

- 657
- 3
- 8
I recommend using GCC (i.e. MinGW) as the compiler. If you do that, your app will generall depend on the msvcrt.dll
that comes with Windows and doesn't need to be installed specially (but it depends on exactly how the GCC compiler is configured). It will also possibly depend on some GCC runtime library DLLs that you can just put in the same directory as your EXE.
MSYS2 is a good development environment for using MinGW on Windows: https://msys2.org
I also made a useful set of tools that is capable of cross-compiling statically-linked MinGW/Qt applications from Linux: https://github.com/DavidEGrayson/nixcrpkgs
The Qt applications I build with nixcrpkgs come out as single, standalone EXEs that do not need to be shipped with any DLLs.

- 84,103
- 24
- 152
- 189