Is there a way to merge C++ executable with DLL’s in VS 2019?

I recently wanted to try my C++ program on another computer (written in VS 2019 Community Edition) and there were some errors that there were some DLL’s missing. Is there any way to merge these DLL’s with the C++ executable (VCRUNTIME140D.dll, and so on).

Answer

Deployment for Visual C++ programs is covered here.

You are allowed to “side-by-side” deploy the required runtime files to just include them in your program setup, zip file, whatever. You’ll find them here: C:Program Files (x86)Microsoft Visual Studio2019CommunityVCRedistMSVC14.29.30133<arch>Microsoft.VC142.CRT

Statically linking the CRT is supported, but it is not recommended. Really the only time it makes sense to use the static CRT is if you are building a setup program/bootstrapper.
As noted, redistributing the debug version is restricted as it’s only intended for testing and development, not “retail” release.

Alternatively, you can just tell users to download and run the Visual C++ 2019 redist package themselves:

X86 (32-bit) application – https://aka.ms/vs/16/release/VC_redist.x86.exe
X64 native application – https://aka.ms/vs/16/release/VC_redist.x64.exe
ARM64 native application – https://aka.ms/vs/16/release/VC_redist.arm64.exe