Static or dynamic linking the CRT, MFC, ATL, etc

前端 未结 7 768
一整个雨季
一整个雨季 2020-12-10 11:19

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 switch

7条回答
  •  无人及你
    2020-12-10 11:43

    There are some downsides:

    • 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)

    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.

提交回复
热议问题