I'm trying to make a binary that can be run on any windows machine without the visual c++ stuff installed (I'm assuming that's what MSVCP120D.dll is however my searching was not very fruitful as to what this actually is). I made a game for an assignment and wanted to have other people (non-devs without VS stuff installed), help me test it but they kept getting errors saying that the above dll is missing. I'm not using any Visual C++ stuff and have the /Za flag set to ensure that it's just ANSI C++. Does Visual Studio support compiling ANSI C++ and if so how do I go about making it not use Visual C++ stuff, if it doesn't support this what compiler should I use?
-
What do you mean by "ANSI C++"? – John Dibling Jan 02 '14 at 19:55
-
The code is ANSI C++, it contains nothing proprietary in it (basically, not Visual C++). – dlkulp Jan 02 '14 at 22:38
-
@dlkulp: The standards body for C++ is ISO. ANSI doesn't even exist anymore (it's now called INCITS, IIRC) – MSalters Jan 03 '14 at 09:23
-
Does this answer your question? [Compile to a stand-alone executable (.exe) in Visual Studio](https://stackoverflow.com/questions/2035083/compile-to-a-stand-alone-executable-exe-in-visual-studio) – phuclv Dec 08 '19 at 10:37
-
@phuclv well this was 6 years ago... but no. I was trying to distribute a debug executable, the accepted answer requires the .NET Framework which I didn't need here. Also, my question was in response to an error people were getting when running my executables. Just a different situation altogether. – dlkulp Dec 08 '19 at 22:37
7 Answers
As you can see here, the MSVCP DLL is the platform's implementation of the C++ Standard Library. In short what that means is you cannot distribute your application without needing the "stuff" that these libraries provide. All compilers regardless of platform would need some kind of implementation of the Standard Library. Typically this is distributed in the form of libraries.
However you can distribute your application so that the "stuff" is built in to your program directly, rather than being shipped in a separate DLL. In order to do this, you must statically link your application to the Standard Library.
There are a few ways to accomplish this. One way is in Project Settings. In "Project" > "Configuration Properties" > "C/C++ Code Generation" > "Runtime Library", choose "Multithreaded (/MT)" as opposed to "Mutithreaded (Static)".
By the way, the "D" in "MSVCP120D.dll" you mentioned above means "Debug." This means that you are trying to distribute a debug build of your program. You should (almost) never do this. Distribute release builds instead.

- 172
- 3
- 10

- 99,718
- 31
- 186
- 324
-
1"you cannot distribute your application without needing the "stuff" that these libraries provide" - not true, you can provide your own CRT implementation, and people sometimes do to get the smallest binaries possible. – paulm Jan 02 '14 at 20:06
-
@paulm: You still need the stuff -- "stuff" being an implementation of the Standard Library. What you're talking about, both here and in your answer, is not bypassing the Standard Library at all, but providing *your own implementation* of the Standard Library as opposed to using the one distributed with the compiler. – John Dibling Jan 02 '14 at 20:15
-
Correct - but you get most of it for free as using most containers and algorithms will still work even without using the CRT DLL at all – paulm Jan 02 '14 at 20:17
-
I want to add, although I'm sure others are very familiar with Visual Studios, that the screen he is talking about can be found by right clicking your solution and going to 'Properties'. (As opposed to Tools > Options where I was looking for a while.) – azoundria Jun 28 '16 at 15:59
-
1Can I just check that is right, you said choose Multithreaded as opposed to Multithreaded (Static) but also said that the solution is to link to the static library. They seem to be opposites to me - but it could be my understanding. – Ant Jan 02 '19 at 16:10
You have three options (in the order I'd recommend):
Don't statically link, instead get people that want to run your game install the visual studio re-distributable package. 32-bit VC 2010 version here: http://www.microsoft.com/en-us/download/details.aspx?id=5555
Statically link the CRT (the dll you don't want to require at runtime) see here for details: How do I make a fully statically linked .exe with Visual Studio Express 2005?
Build an app that doesn't even use the CRT at all. Here you will have to implement your own operator new that calls HeapAlloc(), and operator delete that calls HeapFree(), its an interesting challenge ;). To do this you tell the linker to ignore all default libs.
Build with the static runtime libraries rather than the DLL versions.
Go to Properties, C/C++, Code Generation, Runtime Library and select /MTd or /MT rather than the /MDd and /MD options.

- 21,282
- 4
- 45
- 92
Configure your project to link against the runtime statically rather than dynamically.

- 601,492
- 42
- 1,072
- 1,490
First of all the D on the end of the name indicated a debug build. If you make a release build then it will need it without the D. This is important because microsoft do not allow the debug libraries to be distributed without visual studio.
The machine you are trying to run the program on may already have the release runtime installed as lots of programs use it. If not then install http://www.microsoft.com/en-us/download/details.aspx?id=30679 on the machine ( I think that's the right one but can't check at the moment)

- 29,554
- 19
- 87
- 130
You'll want static linking, that 'builds in' the external library calls into your binary. It does have the added affect of larger binary file, but in your case that doesn't sound like that big of a deal.
On a side note, MSVCP120D.dll is the Microsoft Visual C++ 12 debug DLL
(dynamic link library) that contains all of debug C++ libaries (i.e. iostream
, string
, etc). That library is what you would be 'baking in' to your final binary.
Hope that helps.

- 1
- 1

- 6,625
- 1
- 30
- 39
I encountered this error when I tried to execute my exe on a different machine that had a newer version of Visual Studio on it. You need to change the project properties and re compile in order for this to go away.
To do this:
- Open up solution that you are trying to run
- Right click on the Project file - > Properties
- In Configuration Properties and General, Ensure Platform Toolset is configured to be the correct compiler on your machine. If it is not correct, it should give a message next to it saying that it's not installed.
- Build and run the code again and you should no longer get the issue.

- 353
- 2
- 9