I just developed my first program in C++ and I wanted to share it with one of my friends.
But when he tries to open the exe it gets an error which says "MSVCP140.dll is missing". Why is this issue happening and how can we fix it?

- 952
- 1
- 6
- 12
4 Answers
Either make your friends download the runtime DLL (@Kay's answer), or compile the app with static linking.
In visual studio, go to Project tab -> properties - > configuration properties -> C/C++ -> Code Generation
on runtime library choose /MTd
for debug mode and /MT
for release mode.
This will cause the compiler to embed the runtime into the app. The executable will be significantly bigger, but it will run without any need of runtime dlls.

- 7,285
- 4
- 41
- 61

- 25,446
- 3
- 44
- 78
-
Could you maybe add numbers how big a "hello world.exe" is with dynamic and static linking? – Kijewski Oct 09 '15 at 19:41
-
5@Kay Static linking typically only includes what is needed, not everything in the library. The size increase of the executable will be based on how much of the C runtime is used. – Andy Nov 20 '15 at 15:48
-
Actually, there is no need to link against the debug version of the runtime, except you want to debug the runtime-library. – user1810087 Jun 21 '16 at 15:06
-
6Do not link using /MTd if you plan to redistribute the software. The debug run-time is not included in the redistributable installer. – Andon M. Coleman Aug 10 '16 at 18:20
Your friend's PC is missing the runtime support DLLs for your program:

- 25,517
- 12
- 101
- 143
-
1This is one of the things that applications have to contend with as part of their deployment/setup as not everything your application uses is built into the OS. See [Deploying Native Desktop Applications (Visual C++)](https://msdn.microsoft.com/en-us/library/zebw5zk9.aspx). Note that if your application was a Windows Store application, the Store takes care of deploying the Visual C++ CRT for you. – Chuck Walbourn Oct 07 '15 at 18:11
-
1I am getting the same error on my PC, even though I have the full Visual Studio 2015 installed. The redistributable installer quits, saying that a newer version is already installed. Any thoughts? – matth Jul 12 '17 at 09:42
-
8Be aware, you need to install the version (32 vs 64 bit) of the vc redist that matches how your DLL was compiled, not the OS. – Timothy John Laird Mar 15 '18 at 18:56
That usually means that your friend does not have the Microsoft redistributable for Visual C++. I am of course assuming you are using VC++ and not MingW or another compiler. Since your friend does not have VS installed as well there is no guarantee he has the redist installed.

- 28,141
- 6
- 41
- 93

- 155
- 7