Difference between .DLL And .LIB

来源:互联网 发布:软件测试 大纲 编辑:程序博客网 时间:2024/05/16 02:06

A DLL is loaded dynamically into your process at runtime. A static lib is linked directly into your executable image. E.g. with a static lib you have all the code within the EXE, whereas with a DLL the code is located in another module and only mapped in the process at runtime. (Same applies when creating a DLL instead of EXE - DLLs can in turn depend on other DLLs.)

 

Not to be confused with a LIB file that's actually an "import library". The short story is that when your program depends on an implicitly loaded DLL (http://msdn2.microsoft.com/en-us/library/253b8k2c(VS.80).aspx), it's compiled against the DLL's import (.lib) file which doesn't actually contain any code (unlike the static LIB file referred to above). It just contains references to the DLL that are later resolved at runtime. You can read about this online but the upshot is that when people refer to a ".lib" file they're normally referring to the static LIB file described above (but an import ".lib" file still comes into play for implicitly loaded DLLs).

 

A LIB file is a module consumed by a linker to satisfy external references in other modules. A LIB file generally contains compiled code and associated data, but it may contain nothing more than "import descriptors" that cause the linked image to reference some other module (typically a DLL) at load time.

 

A DLL is a linked image consumed by the operating system loader. It contains fully resolved, linked code and related data, and usually carries a relocation table to allow the loader to place the image into any available memory at load time. A loaded DLL image may be shared between several processes, at runtime, if the DLL is mapped into the same address range in the various processes. In short, a LIB file is a development object, useful only to developers, while a DLL is a deployment object, useful to anyone. --cd

 

 

Thank you. Differences between DLL and Lib is clear for me. I have some doubts.

 

1. What is Dll file Image?

2. What is EXE file Image?

3. What is differeces between Implicit linking and Explicit linking?

-- Thanks Regards,

John

 

an "image" of all or part of an executable program, layed out in the file exactly (or nearly) like it is in memory when it's running. http://en.wiktionary.org/wiki/implicit implied indirectly without being directly expressed http://en.wiktionary.org/wiki/explicit very specific, clear, or detailed e.g. "I gave explicit instructions for him to stay here, but he followed me, anyway."

 

-cd

原创粉丝点击