views:

685

answers:

4

Hello all,

I would like some information on the runtime libraries for Visual Studio 2008. Most specifically when should I consider the DLL versions and when should I consider the Static versions.

The Visual Studio documentation delineates the technical differences in terms of DLL dependencies and linked libraries. But I'm left wondering why I should want to use one over the other. More important, why should I want to use the multi-threaded DLL runtime when this obviously forces my application into a DLL dependency, whereas the static runtime has no such requirement on my application user machine.

+4  A: 

Linking dynamically to the runtime libraries complicates deployment slightly due to the DLL dependency, but also allows your application to take advantage of updates (bug fixes or more likely performance improvements) to the MS runtime libraries without being recompiled.

Statically linking simplifies deployment, but means that your application must be recompiled against newer versions of the runtime in order to use them.

Nick Meyer
+1  A: 

Dynamically linking the runtime library can give you faster program start up times and smaller system memory usage since the dll can be shared between processes and won't need to be loaded again if it's already used by another process.

Laserallan
+1  A: 

I think that main difference is how exceptions will be processed. Microsoft doesn't recommend to link statically to the CRT in a DLL unless the consequences of this are specifically desired and understood:

For example, if you call _set_se_translator in an executable that loads the DLL linked to its own static CRT, any hardware exceptions generated by the code in the DLL will not be caught by the translator, but hardware exceptions generated by code in the main executable will be caught.

Kirill V. Lyadvinsky
+2  A: 

Larry Osterman feels that you should always use the multi-threaded DLL for application programming. To summarize:

  • Your app will be smaller
  • Your app will load faster
  • Your app will support multiple threads without changing the library dependency
  • Your app can be split into multiple DLLs more easily (since there will only be one instance of the runtime library loaded)
  • Your app will automagically stay up to date with security fixes shipped by Microsoft

Please read his whole blog post for full details.

On the downside, you need to redistribute the runtime library, but that's commonly done and you can find documentation on how to include it in your installer.

David Citron