Why do some DLL files need an additional .lib file for linking?

Deadly 提交于 2019-12-04 00:53:26

The lib file is an import library file, which allows the final executable to contain an import address table (IAT) by which all DLL function calls are referenced. Basically, allowing the functions to be looked up.

You can read about it here.

To have Qt generate the lib, add this to the .pro: -

CONFIG+= staticlib

Here's some documentation on how to create libraries.

Bharath Gade

My answer may not be specific to the context but would be useful to most developers asking the same question. This was answered by Anthony Williams

What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?

You don't need a .lib file to use a dynamic library, but without one you cannot treat functions from the DLL as normal functions in your code. Instead you must manually call LoadLibrary to load the DLL (and FreeLibrary when you're done), and GetProcAddress to obtain the address of the function or data item in the DLL. You must then cast the returned address to an appropriate pointer-to-function in order to use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!