Implicit vs. Explicit linking to a DLL

后端 未结 3 795
無奈伤痛
無奈伤痛 2021-01-05 05:17

When one should implicitly or explicitly link to a DLL and what are common practices or pitfalls?

3条回答
  •  别那么骄傲
    2021-01-05 06:05

    I'm assuming you refer to linking using a .lib vs loading a DLL dynamically using LoadLibrary().

    Loading a DLL statically by linking to its .lib is generally safer. The linking stage checks that all the entry points exist in compile time and there is no chance you'll load a DLL that doesn't have the function you're expecting. It is also easier not to have to use GetProcAddress().

    So generally you should use dynamic loading only when it is absolutely required.

提交回复
热议问题