locked
Using /MT or /MD to build dll RRS feed

  • Question

  • I am building a C++ dll that will be consumed by C & C++ applications. I understand that /MT will cause the static library (LIBCPMT.LIB) code to be dumped into my dll, hence no dependency.  /MD will link to import library and will have a dependency on the C++ runtime (MSVCP100.dll).

    My doubts:

    1. In /MD option do I have to make sure the right version of the C++ runtime dll, the one's import library I had linked to during development, exists on Windows OS?

    2. Do I need to care about what C/C++ runtime the applications using my dll were linked to ? I want to use the C++11 features but want to make sure old C++ applications built using VS2008 for example can still consume my dll.

    3. I am planning to use VS 2012 RC now and I think their C++ runtime libraries got updated. Will there be any dependency again on what version of Windows that code will execute on or what libraries the applications consuming my dll used?


    • Edited by Shawn Dan Thursday, August 2, 2012 1:58 AM
    Thursday, August 2, 2012 1:30 AM

Answers

  • 1) and 3) Visual Studio uses /MD by default to compile your projects which means you will have to ensure proper dll exists on target OS. But before developing you can always visit Visual Studio site and see compatibility with different OS. Visual 2012 RC compiled programs should execute correctly over Vista+ and for pre Vista you need to use multi target setting.

    See http://blogs.msdn.com/b/visualstudio/archive/2012/05/18/a-look-ahead-at-the-visual-studio-11-product-lineup-and-platform-support.aspx

    2) Assuming your dll can now run in the target OS, regarding dealing with application you only have to make sure at the binary level you are not exposing anything that is tied to a particular compiler i.e keep abstract binary interface. 

    • Marked as answer by Shawn Dan Thursday, August 2, 2012 9:58 PM
    Thursday, August 2, 2012 6:55 PM