1

This is somewhat an addition to this question (MSVCP140.dll missing).

I am trying to compile a program for a windows machine. Something huge to note here is I do not have the privileges to install software on it, but I may run executables.

Every time I run it on the windows machine in question I get a missing MSVCP140.dll problem. I have followed the solution of the question I have linked (which is static linking) and for some VERY odd reason I am still getting the error (even though I know this enabled the program to run on colleagues computers when they were getting the same error).

Is there anything more I can do that will make the program (for lack of better terms) fully portable? Any more settings I need to change in VS such that it will fully compile the libraries into the executable?

I am going to further stress the fact I have seen the solution to use static linking using the /MT option for compilation and I am still getting missing .dll problems.

I tried copying MSVCP140.dll next to my executable and it did solve the issue, but there is another missing .dll and I cannot incrementally add .dlls until the program starts working. I am happy to bundle all the .dlls with the program if that is the only solution but I would like to know which ones are needed so I don't have to copy my entire system32 folder out of desperation.

Community
  • 1
  • 1
ZoSal
  • 561
  • 4
  • 21
  • First of all you must KNOW your app then you should know its dependencies, a missing dependency loaded with LoadLibrary() may for example be hard to detect or go unnoticed for a long time. That said you can inspect dependencies with a small tool called DependencyWalker. Also note that if you statically linked all C++ RT DLLs then it should really work on every single machine so there should be something else you're missing there... – Adriano Repetti Jun 21 '16 at 15:03
  • @AdrianoRepetti Believe me, I am very confused as to why static linking is not working. – ZoSal Jun 21 '16 at 17:53
  • Do you have a dependency to any other (deployed) DLL which depends on MSVCP140? You should explore your dependencies tree with Dependency Walker to get a better overview – Adriano Repetti Jun 21 '16 at 20:10
  • @AdrianoRepetti I've used Dependency Walker and provided I'm using it correctly I'm getting these reported [errors](https://i.gyazo.com/7939ebbc9dfcf04a58876d0339aa464e.png). Aside from that I have [these](https://i.gyazo.com/54b05b6e4bb1267624b3f134a920ea63.png) .dlls, which themselves have many dependencies. I am going to see if just these 3 .dlls will allow me to run the executable on the machine I need to. – ZoSal Jun 21 '16 at 22:00

1 Answers1

2

Have a go at using dependency walker to figure out what dlls you need, and why you need them. This can be enlightening, and lead to a path of cutting out many dependencies by using alternatives. If you are sure you aren't importing certain functions at consumer runtime (e.g. you are only importing them for debug purposes), then you can choose to delay load them.

Preet Kukreti
  • 8,417
  • 28
  • 36