2

I'm trying to compile my program so it create a standalone exe. Actually I have 2 problems :

I did go to Properties -> C/C++ -> Code generation -> Runtime library and changed for Multi-threaded (/MT).

After I did this, the size of the .exe increased, but when I try to use it on another computer, the error "can't run this program, you need a DLL named : msvcp140d.dll"

This are the 2 problems, I don't understand why it asks me to use a debug version of a DLL since i'm compiling a release version and I don't understand why it asks me to use a DLL since I thought they are statically linked /:

P.S : I'm trying to compile an OpenCV3.0 project. I don't know if it helps or not :/

EDIT : One problem has been solved : I was using opencv_imgproc310d.dll in the release linker making my program using MSVCP140d.dll. Now I still have the problem that the exe is not a standalone. It requires dll to works. (I just upadted my VS so I have the latest version). Thanks

Raph Schim
  • 528
  • 7
  • 30
  • As far as I know the fact that you use multithreaded does not mean you are using the static runtime. It is a different thing. – Germán Diago Jan 23 '17 at 09:15
  • http://stackoverflow.com/questions/20890458/compile-c-in-vs-without-requiring-msvcp120d-dll-at-runtime I saw this solution on this post :/ – Raph Schim Jan 23 '17 at 09:17

1 Answers1

1

You're correct that if you use /MTd flag, that you do not need external dependencies (like Microsoft dll files). But because that flag size of the executable increases (as it contains more binary code).

Your problem "can't run this program, you need a DLL named : msvcp140d.dll" is because you did not set Runtime Library for both configurations:

  • Debug: you need to set Multi-threaded Debug (/MTd) flag
  • Release: you need to set Multi-threaded (/MT) flag

Be sure to set both, otherwise only one configuration will run.

  • I did what you said. I modified both, but the result is still the same. I can't run the exe file. and the error message still appear. And it says that I don't have a ...d.dll on my computer (once again, it's strange since I built a release version and asks me for a debug DLL ... /:) – Raph Schim Jan 23 '17 at 09:31
  • do you have multiple projects, if so did you set them properly? –  Jan 23 '17 at 09:32
  • I have only 1 project. And I think I set him properly. – Raph Schim Jan 23 '17 at 09:35
  • that's strange, try to clean and build the project, also the project compiles and runs on your computer normally? –  Jan 23 '17 at 09:37
  • I cleaned it and rebuilt it several times already. And yes, the project compiles and run on my computer. – Raph Schim Jan 23 '17 at 09:37
  • Ok! I am half stupid! I linked the debug version of the DLL in the release property, making it using msvcp140d.dll and msvcp140.dll. Now that I modified that, It don't asks me for msvcp140d.dll anymore, but it is still not a standalone, since I need DLL's to make it works /: – Raph Schim Jan 23 '17 at 09:46
  • On the computer where you compile, you always need installed dependencies. /MTd and /MT flags just tell the compiler to build in the dependencies. After that such compiled executable should not be dependent on external dependecies. –  Jan 23 '17 at 09:50
  • It is what's happening actually. I build with /MT and /MTd, I have all dependencies installed on my compiling computer, and when I try to use the exe on another computer, it fails, telling me that I need DLL's to works ... – Raph Schim Jan 23 '17 at 09:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133790/discussion-between-fr3nzy90-and-raphael-schimchowitsch). –  Jan 23 '17 at 09:55