Implicit vs. Explicit linking to a DLL

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

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

3条回答
  •  萌比男神i
    2021-01-05 06:09

    It is fairly rare to explicitly link a DLL. Mostly because it is painful and error prone. You need to write a function pointer declaration for the exported function and get the LoadLibrary + GetProcAddress + FreeLibrary code right. You'd do so only if you need a runtime dependency on a plug-in style DLL or want to select from a set of DLLs based on configuration. Or to deal with versioning, an API function that's only available on later versions of Windows for example. Explicit linking is the default for COM and .NET DLLs.

    More background info in this MSDN Library article.

提交回复
热议问题