1

Recently I have been learning C++ and to test some of the skills I've been learning I made a simple blackjack game in a console application. My friend asked if I could send him it so he could try it out, but when he attempted to run it he got an error that said "The code execution cannot proceed because MSVCP140D.dll was not found". I already know the easy fix to this problem is just having him download Visual Studio with the C++ redistributable package, but I was wondering if there was a fix I could implement to allow the file to run for people who don't have visual studio installed. I was wondering if anyone could help me get past this issue or link an article on how to fix it. Thanks

Edit: For some reason despite building the program in release mode before sending him it, he still gets the error for the missing debug DLL (MSVCP140D.dll), another debug DLL (VCRUNTIME140D.dll), and urctbased.dll

cc0721
  • 23
  • 3
  • *I already know the easy fix to this problem is just having him download Visual Studio with the C++ redistributable package* -- Installing a full blown IDE and compiler is not an easy fix. -- *but I was wondering if there was a fix I could implement to allow the file to run for people who don't have visual studio installed.* -- Now, would you think that Microsoft would have no way for their programs compiled with Visual C++ to be able to be distributed to the public? Some of the programs running on your computer now were compiled using Visual C++. – PaulMcKenzie Jul 27 '21 at 16:34
  • 2
    `MSVCP140D.dll` is the *debug* version of the runtime, and the debug version is not redistributable. – Remy Lebeau Jul 27 '21 at 16:35
  • Set the runtime to `Multi-threaded (MT)` in release version instead of `MTd`. If I remember correctly, it can be found in `Code Generation`. On doing so, Visual C++ will embed VC++ runtime library in your app. – Asesh Jul 27 '21 at 16:50
  • @Asesh thank you very much! This fixed the issue. Would you mind re-commenting that as an answer so I can mark it as an answer to my question? – cc0721 Jul 27 '21 at 17:00
  • The problem with that as an answer is there is no way to connect the contents of your question with that as an answer. It's purely an experience thing. Normally we hates the screenshot, my Precious, but in this case a picture of the dialog with the incorrect configuration setting is called for. – user4581301 Jul 27 '21 at 17:14
  • There are other SO threads that solves the problem that is related with this question. So I will link one of the most popular threads related to your question and mark it as duplicate – Asesh Jul 27 '21 at 18:32
  • 1
    Does this answer your question? [Should I compile with /MD or /MT?](https://stackoverflow.com/questions/757418/should-i-compile-with-md-or-mt) – Asesh Jul 27 '21 at 18:33

1 Answers1

3

The "D" in "MSVCP140D.dll" means it's a Debug library, which is only used when you've built your application in Debug mode. Change to Release mode and you should be fine.

enter image description here

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
  • I already tried this and he said he was still getting the same error in the release build. He must've been mistaken about what the error code was in the release version I sent him – cc0721 Jul 27 '21 at 16:33
  • Related/dupe: [Visual C++ executable and missing MSVCR100d.dll](https://stackoverflow.com/questions/10406807/) – Remy Lebeau Jul 27 '21 at 16:34
  • @cc0721 or you didn't properly set Release mode. I added a picture to the answer. – Mark Ransom Jul 27 '21 at 16:41
  • It looks exactly like the screenshot you sent (apart from the fact mine says x86 instead of win32) and the one that I built while on release had a much smaller file size than the debug one too which leads me to believe they're different. My config is also set to release in the properties page too. I don't know what else to change – cc0721 Jul 27 '21 at 16:49
  • @cc0721 the only other thing I can suggest is doing a "rebuild all" next time you compile. – Mark Ransom Jul 27 '21 at 16:51