Why does visual studio create .LIB with .DLL?

I have a "Logger" project in which the configuration type is a DLL.

"Logger" uses "libconfig" (open source parser). I currently have a separate project for "libconfig" and its configuration type is -.lib

I added "libconfig" to the Logger frameworks and links with:

  • link depedencies = true
  • use dependency library inputs = false

On the Logger linker command line, I see: / IMPLIB: "path \ to \ Logger.lib"

My question is: Why does Logger.lib need to be created? I see / OUT = "path \ to \ Logger.dll", but I'm trying to get the visual studio build process.

From the M $ IMPLIB doc , I see its part of the LINK process. I still do not understand.

Edit: I did not mention how to use the Logger DLL. My application will load it at runtime (since this function is only required for certain cmd command line arguments)

+8
c ++ visual-studio dynamic-linking libconfig
source share
2 answers

The DLL contains the code. The .lib file basically contains stubs for functions in the file that simplify (and relatively quickly) the linker to put the correct information in the executable file for using functions in the DLL.

Ultimately, there is no reason why they should do this - basically it keeps the linker a bit simpler and faster, because it doesn't need (at least the same) special code to handle static and dynamic libraries. They can work around this by adding both codes and link information to a single file, but this will increase the file size (a bit).

Most likely, this does not mean that there is a lot, but when Windows was new, quite a lot of programs were still distributed on 360-kilogram disks, so minimizing the file size that you distributed to users was considered quite important.

+11
source share

For an exe using your logger.dll, you will need to associate it with logger.lib. Without lib, exe cannot be built. The library contains stub functions that satisfy calls made by the exe code. (At run time, stubs transfer calls to a DLL.)

+4
source share

All Articles