静态或动态链接CRT,MFC,ATL等 [英] Static or dynamic linking the CRT, MFC, ATL, etc

查看:175
本文介绍了静态或动态链接CRT,MFC,ATL等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回到上世纪90年代,当我第一次开始使用MFC我用来动态链接我的应用程序和运送相关的MFC DLL。这导致我一些问题(DLL地狱!),我切换到静态链接 - 不只是为MFC,而是为CRT和ATL。除了较大的EXE文件,静态链接从来没有给我带来任何问题 - 所以有其他人遇到的任何缺点吗?有再次访问动态链接的好理由吗?我的应用程序主要是STL / Boost如今的FWIW。

Back in the 90s when I first started out with MFC I used to dynamically link my apps and shipped the relevant MFC DLLs. This caused me a few issues (DLL hell!) and I switched to statically linking instead - not just for MFC, but for the CRT and ATL. Other than larger EXE files, statically linking has never caused me any problems at all - so are there any downsides that other people have come across? Is there a good reason for revisiting dynamic linking again? My apps are mainly STL/Boost nowadays FWIW.

推荐答案

有一些缺点:


  • 更大的exe大小(如果您运送多个exe的话)。

  • 使用其他依赖或假设动态链接的DLL

  • 具有独立静态链接的DLL之间的不同c运行时(没有跨模块分配/释放)

  • 没有共享组件的自动服务(无法让第三方模块供应商更新其代码以修复问题,无需重新编译和更新应用程序)

  • Bigger exe size (esp if you ship multiple exe's)
  • Problems using other DLL's which rely on or assume dynamic linking (eg: 3rd party DLL's which you cannot get as static libraries)
  • Different c-runtimes between DLL's with independent static linkage (no cross-module allocate/deallocate)
  • No automatic servicing of shared components (no ability to have 3rd party module supplier update their code to fix issues without recompiling and updating your application)

我们为我们的Windows应用程序进行静态链接,主要是因为它允许xcopy部署,这是不可能的安装或依赖于SxS DLL的工作方式,因为过程和机制没有很好的文档或容易远程。如果你在安装目录中使用本地DLL,它会有点工作,但它不是很好的支持。无法轻松地进行远程安装而不通过远程系统上的MSI是我们不使用动态链接的主要原因,但(如你所指出的)静态链接还有许多其他好处。每个人都有利弊;希望这有助于枚举他们。

We do static linking for our Windows apps, primarily because it allows xcopy deployment, which is just not possible with installing or relying on SxS DLL's in a way which works, since the process and mechanism is not well documented or easily remotable. If you use local DLL's in the install directory it will kinda work, but it's not well supported. The inability to easily do remote installation without going through a MSI on the remote system is the primary reason why we don't use dynamic linking, but (as you pointed out) there are many other benefits to static linking. There are pros and cons to each; hopefully this helps enumerate them.

这篇关于静态或动态链接CRT,MFC,ATL等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆