Exp 的用途是什么? . lib 和. dll 的区别是什么?

在编译和链接期间,使用。解释?有什么区别。Lib 和。DLL?我知道。将使用 lib,而链接和。在运行程序时将使用 dll。但是。Lib 和。DLL?

Lib 文件是否包含来自. dll 文件的函数的代码? 为什么需要使用两个独立的文件?

请澄清一下。

22711 次浏览

In the case of an import library for a DLL, the .lib file does not contain any actual code at all. It basically contains just a list of the functions in the associated DLL -- enough for the linker to embed a reference to that DLL into something linked with the library, but not much else.

A .exp file is an export file -- basically just about the same as a .lib file. It's used (at least primarily) when you have a circular dependency. For example, assume you have a DLL that acts as a plug-in for an executable. The executable supplies some exported functions for use by plug-in DLLs, but also needs to be able to call some functions in the plug-ins as well (e.g. to load and initialize a plug-in).

The DLL won't link until the executable is built to provide a .lib file -- but the executable won't link until the DLL is built to provide a .lib file. To break the dependency, you run the linker against the executable, which fails (because it can't find a .lib file for the DLL), but will produce a .exp file. You then link the DLL against the .exp file for the executable. You can then re-run link to produce the executable, using the .lib file for the DLL.