3

When I run my program on a freshly installed computer, it tells me that Visual C++ Redistributable Package 2015 (namely, MSVCP140.dll) needs to be installed on the computer in order to run my dynamically linked program.

I understand that static linking would solve the problem - however, that just doubles the size of my executable.

Isn't there a way to suppress visual studio features so the redist package is not necessary and still use the visual studio compiler, as I'm not used to the alternatives like mingw etc.

Or does the redist package actually contain the STL? I can hardly imagine that.

user66875
  • 2,772
  • 3
  • 29
  • 55
  • Marked as duplicate, even though the quesiton linked is for another version of Visual Studio, it still applies. – peterchen Aug 08 '16 at 12:33
  • As stated, I do understand that static linking solves the problem. My question is though, why I even need to deliver any DLL/redist package if I just use STL features. Does the redist package contain the STL? – user66875 Aug 08 '16 at 12:35
  • Oh, OK. Yes, I've seen mentioned before that the standard library contains specializations for some commonly used algorithms and types. (this could e.g. be a specialization of a template for which a particular optimization can be enabled manually, or types that are so common that their code should reside in the runtime instead of each binary.) – peterchen Aug 08 '16 at 12:38

2 Answers2

4

AFAIK you only have 2 options : 1. static linking - no dll dependency, but huge size 2. dynamic linking - you need correspond dlls , relativelly small executables.

As for #2 you also have 2 options :

  1. install redist as standalone package
  2. put this dll's in same directory with exe . It's "legal" from MS stand point. (privat assembly ?)

Hope it helps .

user1503944
  • 387
  • 2
  • 16
1

The 'redist packages' contain basically the libraries. If you don't use any library functionality, you will not need them, but otherwise there is no way - you can't call a library function and then don't have it.

That means remove all includes with <>, and you are good.

Note that if you do use library functions, that is hardly an option - you really don't want to recode strlen, fopen, and so on yourself.

Aganju
  • 6,295
  • 1
  • 12
  • 23
  • With library, you mean the STL? I'm using tons of STL features like ``, `` etc.. But why do those require the redist packages? I mean, if I compile it with mingw, I do not need to distribute any redist packages or dlls, no? – user66875 Aug 08 '16 at 12:28
  • Yes, the functionality behind all those std stuff is in the redistributables. Either you have them, or you link the functionality statically in (and your executable gets larger). It has to come from somewhere. - I have no knowledge about mingw. – Aganju Aug 08 '16 at 12:46
  • @user66875 - mingw *is* using a set of DLLs, but is designed to use the same set that Windows itself is using. Your problem is that you are introducing a new compiler version to some computer. Then you will have to install the new runtime, once only. The next program installed will get it for free. – Bo Persson Aug 08 '16 at 14:30
  • It should be noted that what mingw does is against the rules. :-) Microsoft probably won't intentionally break mingw programs, but they're not promising to keep them running, either. – Harry Johnston Aug 09 '16 at 02:52