2

Let's say I built the following C++ code into HelloWorld.exe with Visual Studio 2015, targeting Release, platform x64.

#include <iostream>

int main()
{
    std::cout << "Hello world!!" << std::endl;
    return 0;
}

Years ago, I could simply copy msvcp###.dll (or msvcr###.dll for C) along with HellowWorld.exe and have a runnable program.

I have just installed VS2015, and now it seems that I can't just bring msvcp140.dll along. There seems to be 70~ish api-ms-win-.....dll files in my System32 folder that need to come with it.

I know the best policy is to have them install the redistributable... but for cases where they can't, copying the .DLL used to be a viable alternative. Is it still the case? Am I missing something easy?

To sum up: I had thought I could just copy msvcp140.dll and have it work, but this doesn't seem to be the case. Am I wrong?

Note: I don't see the api-ms-....dll files in the list of things you are allowed to redistribute. Or is it understood this is part of the 2015 runtime and that comes along with it?

kmort
  • 2,848
  • 2
  • 32
  • 54
  • 3
    Nope. It's bucket full of DLLs, debug DLLs, multithreaded DLLs, and DLLs of every smurfing kind. You also want these DLLS protected and walled away from simple tampering because one quick file replacement and your PC is being welcomed to the Borg Collective. – user4581301 Jun 16 '16 at 21:15
  • 1
    You are not wrong. Just do a static build and tell anyone who complains about the file size to get a new computer. – Christopher Oicles Jun 17 '16 at 02:23

2 Answers2

1

Rather than dealing with installing redistributables, I tend to statically link the runtime (/MT and /MTd compiler options).

It does result in a larger file size, but it's smaller than shipping the DLLs by far.

Mitch
  • 1,839
  • 16
  • 23
0

You can distribute the VC 2015 redistributable with your installer.

https://www.microsoft.com/en-us/download/details.aspx?id=48145

If that's not an option, statically link it.

You can also run depends to determine what other DLL's you need. You can ignore api-ms*.dll's: Dependency Walker: missing dlls

James
  • 270
  • 1
  • 10