Question : DLL vs LIB implicit linking

When you are linking external code into a program. You can link in a library (LIB) in two ways as I understand. The lib file could contain the actual code, or the lib file can contain only the symbols in the code and the actual code is reference somewhere else in another dll on the system. Does this sound correct? If so, is there a way to determine what the case is by something in the LIB file?

Thanks,
Matthew

Answer : DLL vs LIB implicit linking

In case of a DLL reference, the .LIB is just an import library which contains information the linker needs to resolve external references to exported DLL functions, so the system can locate the specified DLL and exported DLL functions at run time (see also http://msdn.microsoft.com/en-us/library/ms682592%28VS.85%29.aspx - "Dynamic-Link Library Creation" - and the pages linked from there). In case of a static library you are right, the .LIB file contains all the code that is needed to resolve the used functions and the code is placed into your executyble by the linker directly, see http://msdn.microsoft.com/en-us/library/ms235627%28VS.80%29.aspx ("Walkthrough: Creating and Using a Static Library").

You can check the contents of a .LIB file by using either lib.exe or dumpbin.exe on the command line, an import library should not contain any actual code.

Random Solutions  
 
programming4us programming4us