Visual Studio 2008,运行时库使用建议

发布于 2024-07-30 07:20:37 字数 236 浏览 4 评论 0原文

我想要一些有关 Visual Studio 2008 运行时库的信息。最具体地说,什么时候应该考虑 DLL 版本以及什么时候应该考虑静态版本。

Visual Studio 文档描述了 DLL 依赖项和链接库方面的技术差异。 但我想知道为什么我应该使用其中一个而不是另一个。 更重要的是,为什么我要使用多线程 DLL 运行时,因为这显然会迫使我的应用程序产生 DLL 依赖关系,而静态运行时在我的应用程序用户计算机上没有这样的要求。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

余生再见 2024-08-06 07:20:37

由于 DLL 依赖性,动态链接到运行时库会使部署稍微复杂化,但也允许您的应用程序利用 MS 运行时库的更新(错误修复或更可能的性能改进),而无需重新编译。

静态链接简化了部署,但意味着您的应用程序必须针对较新版本的运行时重新编译才能使用它们。

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.

ゃ懵逼小萝莉 2024-08-06 07:20:37

Larry Osterman 认为您应该始终使用多线程 DLL< /a> 用于应用程序编程。 总结一下:

  • 您的应用程序将会更小
  • 您的应用程序将加载得更快
  • 您的应用程序将支持多线程,而无需更改库依赖项
  • 您的应用程序可以更轻松地拆分为多个 DLL(因为只会加载运行时库的一个实例)
  • 您的应用程序将自动与 Microsoft 提供的安全修复程序保持同步

请阅读他的 整个博客文章了解完整详细信息。

不利的一面是,您需要 重新分发运行时库,但这很常见,您可以找到有关如何将其包含在安装程序中的文档

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.

孤独患者 2024-08-06 07:20:37

动态链接运行时库可以为您提供更快的程序启动时间和更小的系统内存使用量,因为 dll 可以在进程之间共享,并且如果它已被另一个进程使用,则不需要再次加载。

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.

作死小能手 2024-08-06 07:20:37

我认为主要区别在于如何处理异常。 Microsoft 不建议静态链接到 DLL 中的 CRT,除非特别需要并理解这样做的后果:

例如,如果您在加载链接到其自己的静态 CRT 的 DLL 的可执行文件中调用 _set_se_translator,则 DLL 中的代码生成的任何硬件异常都不会被翻译器捕获,但主可执行文件中的代码生成的硬件异常将被捕获。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文