When I want to call some Windows function, like MessageBox I can import it from user32.dll and call (with LoadLibrary and GetProcAddress). But there is also a static library that Visual C++ uses, so I don’t need to manually load DLLs and functions. How do they work? Do they contain wrappers that call LoadLibrary/GetProcAddress every time I call a function?
Share
The “static library” that you’re referring to is actually an import library. This type of library contains records that tell the linker which library each function actually exists in, and doesn’t contain any code itself. The linker creates import records in the executable, which the loader resolves at load time. This fixes up the addresses used at runtime so your code doesn’t need to explicitly call
LoadLibraryandGetProcAddress.