6

I have the following problem: I use Microsoft Visual Studio 2012 and it adds msvcp110.dll to my release. I've read some posts here and there and I know that it's caused by the fact I use both iostream and string and that links it to my program. I have no problem using this on my PC, but I'd like to show it to others. So my question is, how do I, as painless for others as possible, can get around the issue, and still use some basic std goodies? I know that others could just install Visual Studio Runtime stuff but it's kind of painful.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Krzysztof Piszko
  • 1,355
  • 3
  • 12
  • 17

1 Answers1

9

If you intend to keep your application dynamically-linked, your end-users need to install the Visual C++ Redistributable for Visual Studio 2012.

This is the preferred way to deliver applications for the following reasons:

  1. Binary size - Your application binary will be smaller, because the library functions are not linked in.
  2. Security - The Microsoft redistributable DLLs can be updated by Windows Update. In the event that a vulnerability is found in one of their libraries, they can fix it, and all dynamically-linked programs are immediately no longer vulnerable.
  3. Memory footprint - If multiple processes are all using the same DLL, it only needs to be loaded into (read-only) memory once. All process share a copy of the DLL's text in memory, reducing the combined overall memory usage of the processes.

Alternatively, you could statically link your executable. Do this by changing the build options for the program in Visual Studio.

In Visual Studio 2010, this is under Configuration Properties > C/C++ > Code Generation > Runtime Library.

enter image description here

The default (/MD / /MDd) tell VS to link against their runtime DLL.

To statically link, you want to change this to one of the non-DLL options (/MT / /MTd) Make sure to select the correct Debug/Non-Debug version (the little d in the switch).


See also:

Community
  • 1
  • 1
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • Thanks for an answer! I know that end-user should have this to make things go faster, but this is, at the moment, a small program and I just want to send it to few people. But back to the issue - I selected the option in the screenshot, but it's still not working. Did I miss something? Here's my [code generation window](http://i.imgur.com/byqKHC5.png). – Krzysztof Piszko Jan 13 '14 at 23:59
  • Did you change it? It's still set to DLL. You want `Multi-threaded (/MT)`. I'll re-word my answer. – Jonathon Reinhart Jan 14 '14 at 00:08
  • Ah, I see - got confused. I'll check out if that works tomorrow, now it's time for me to go to bed. Thanks for help! – Krzysztof Piszko Jan 14 '14 at 00:11