1
votes

I know how to implement both static and runtime dll linking, but I'm more interested in why dll's LIB (static library) is needed in static dll linking? Usually LIB is noting but a container of code (method implementations), but comparing static dll linking and runtime dll linking (LoadLibrary, GetProcAddress...) I get the impression that LIB is used to somehow get dll procedure addresses? Maybe I'm totally wrong, I don't know..

1
You are about right. With a static library the LIB file contains the code. With a dynamic library (DLL) the LIB file only contains the info needed by the linker to find the functions in the DLL.Bo Persson
Thx. That's what I wanted to know.Tracer

1 Answers

0
votes

The LIB library that goes with a DLL contains "stubs" that "connect" your code that you've written with the code in the DLL. Typically, it is just a "jump instruction" to the actual code in the shared library. It also contains a reference to the actual shared library to be used, so that the loader that brings in the executable into memory can load the relevant shared libraries at that point.

When you use runtime linking for using a shared library, your code is responsible for loading the library, and resolving which functions in the shared library are being used.