2

For a MSVC9 Win32 project following options are shown under Configuration Properties -> C/C++ -> Code Geberation -> Runtime Library:

/MT, /MTd, /MD, /MDd

is it correct that for a DLL /MTd should be used and for static lib /MDd?

Thanks.

Azodious
  • 13,752
  • 1
  • 36
  • 71
  • 1
    See the reference: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx it's just for the choice of run-time library, but not for your own code. – Stan Jul 23 '11 at 08:39
  • Yes, i went through that page but couldn't make any sense. can you pls explain in simpler words. Thanks. – Azodious Jul 23 '11 at 08:45
  • For example, if you choose /MT option, the run-time function you call will be put into your program (whether it's DLL or static Lib). The problem that should be noticed is the possible conflict when other people use your DLL or static Lib. – Stan Jul 23 '11 at 09:12

1 Answers1

8

There are two issues that are at play here.

First, you need to choose if you want the Debug version of the CRT or the Release version. The debug versions have special checks and code paths designed to help you catch bugs while writing an application. You should not use them for the final release version of an application because they can slow down its execution, and because they are not freely redistributable.

Then, you need to decide if you want to statically link the run-time to your application, or if you want to use it dynamically from a DLL. Static linking allows you to create a standalone EXE file with no dependencies on any DLL files; it effectively compiles the run-time code into your application's binary. This can make deployment easier, but it comes at the cost of not being able to take advantage of security and other updates that are made to the run-time DLLs. You'll have to recompile your application in order to take advantage of the new run-time updates. Dynamic linking is the typical (and recommended) path for Windows applications. It means that your application will require the appropriate versions of the CRT DLLs to be present in order for it to run, but it allows the run-time libraries to be easily updated and means that multiple programs can share the same code, reducing their size on disk.

So, /MD means dynamically-linked and /MT means statically-linked. The lower-case d after each option indicates that the debug version of the run-time libraries is used.

/MD = dynamically-linked to release (redistributable) version of CRT

/MDd = dynamically-linked to debug (non-redistributable) version of CRT

/MT = statically-linked to release (redistributable) version of CRT

/MTd = statically-linked to debug (non-redistributable) version of CRT

More information is available on MSDN.

Community
  • 1
  • 1
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574