.exp有什么用,.lib和.dll有什么区别? [英] What is the use of .exp and what is the difference between .lib and .dll?

查看:22
本文介绍了.exp有什么用,.lib和.dll有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译和链接过程中,.exp有什么用?.lib 和 .dll 有什么区别?我知道将使用 .lib,而在运行程序时将使用链接和 .dll.但 .lib 和 .dll 到底有什么区别?

During compilation and linking, what is use of .exp? What is the difference between .lib and .dll? I know that .lib will be used, while linking and .dll will be used when running the program. But what exactly is the difference between .lib and .dll?

.lib 文件是否不包含来自 .dll 文件的函数的代码?使用两个单独的文件有什么需要?

Does .lib file not contain the code for the functions coming from .dll files? What is the need for using two separate files?

请澄清.

推荐答案

对于 DLL 的导入库,.lib 文件根本包含任何实际代码.它基本上只包含关联 DLL 中的函数列表——足以让链接器将对该 DLL 的引用嵌入到与库链接的内容中,但除此之外不多.

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.

.exp 文件是一个导出文件——基本上与 .lib 文件大致相同.当您有循环依赖时(至少主要)使用它.例如,假设您有一个用作可执行文件插件的 DLL.可执行文件提供一些导出函数供插件 DLL 使用,但还需要能够调用插件中的一些函数(例如加载和初始化插件).

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).

在生成可执行文件以提供 .lib 文件之前,DLL 不会链接——但在生成 DLL 以提供 .lib 文件之前,可执行文件不会链接.为了打破依赖关系,您针对可执行文件运行链接器,这会失败(因为它找不到 DLL 的 .lib 文件),但生成一个 .exp 文件.然后将 DLL 链接到可执行文件的 .exp 文件.然后,您可以使用 DLL 的 .lib 文件重新运行链接以生成可执行文件.

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.

这篇关于.exp有什么用,.lib和.dll有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆