Is it possible to link all libraries dynamically (that is, with the / MD key), and the standard library - statically (/ MT)? The static standard WINDOWS library is called LIBCPMT.LIB.

https://support.microsoft.com/uk-ua/help/154753/description-of-the-default-c-and-c-libraries-that-a-program-will-link

  • The link contains outdated information, as much as 2008. See Introducing the Universal CRT . - VTT
  • I have a suspicion that in fact you want your dynamic libraries to link runtime dynamically, but at the same time import all runtime library functions from the .exe file so as not to drag a bunch of separate runtime libraries. - VTT

1 answer 1

Not. These keys tell the linker what runtime to use. If you link 2 libraries to one exe / dll file, which are compiled with different versions of runtime, the linker will swear that you have duplicated all the functions of these runtimes. For example, two versions of the operator new , one static, the other dynamic, which one should link?

If you really want, then you can link to the .exe file compiled with / MD ..dll, which is compiled with / MT, because For the "border" dll'ki runtime does not leak. But it's dangerous to do so, because it may happen that the object was created in .exe through the static new operator, and deleted inside the .dll through the dynamic delete . Yes, there are many such jokes.

  • This means that the /md compiler key, and the linker key are /nodefaultlib , and then with the handles, dynamic msvcrt.lib (the one with the /md key) and static libcpmt.lib (the one with /mt ). I remind you - the default key is /md . But that doesn't mean anything, if '/ nodefaultlib' is the same? Is it possible to do this? - ilw
  • @Andreyua This is radically different from what you are asking in your question. The phrase "pens - dynamic msvcprt.lib" in general without meaning. Describe in detail what you still want to get. /nodefaultlib usually means that standard libraries will not be used. - VTT
  • dynamic msvcprt.lib - I fixed it. standard libraries will not be used - so standard is this: msvcrt.lib and this: libcpmt.lib . - ilw
  • @Andreyua msvcprt.lib is an import library for dynamic runtime connection. Connect it with your hands does not make sense. Connecting msvcrt.lib and libcpmt.lib at the same time again does not make sense and does not correspond to what is written in the question. - VTT
  • msvcprt.lib is for static (and you already forgot about it, but I fixed it, I say, look at that above ...). msvcrt.lib and libcpmt.lib at the same time again does not make sense - explain why ... - ilw