DLL 和 LIB 文件 [英] DLL and LIB files

查看:23
本文介绍了DLL 和 LIB 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DLL 和 LIB 文件有什么区别?DLL 文件里面有什么,LIB 文件里面有什么?创建可执行文件是否需要 DLL 和 LIB 文件?

What is the difference between a DLL and a LIB file? What is inside a DLL file and what is inside a LIB file? Are both DLL and LIB files necessary to create an executable?

推荐答案

DLL 文件是最终的构建产品,它是您安装在客户机器上的文件.它与 EXE 文件非常相似,结构相同,但可以按需加载到另一个程序中.

A DLL file is the final build product, that's what you install on your customer's machine. It is very similar to an EXE file, same structure, but can be loaded on demand into another program.

LIB 文件用于构建您的程序,它只存在于您的构建机器上,您不会发布它.有两种.静态链接库是一袋 .obj 文件,收集到一个文件中.当需要解析外部标识符时,链接器会从文件中挑选任何代码块.

A LIB file is used to build your program, it only exists on your build machine and you don't ship it. There are two kinds. A static link library is a bag of .obj files, collected into a single file. The linker picks any chunks of code from the file when it needs to resolve an external identifier.

但与 DLL 更相关的是,LIB 文件也可以是导入库.然后它是一个简单的小文件,其中包含 DLL 的名称和 DLL 导出的所有函数的列表.当您构建使用 DLL 的程序时,您需要将它提供给链接器,以便它知道外部标识符实际上是 DLL 导出的函数.链接器使用导入库将条目添加到 EXE 的导入表中.然后 Windows 在运行时使用它来确定需要加载哪些 DLL 才能运行程序.

But more relevant to DLLs, a LIB file can also be an import library. It is then a simple small file that includes the name of the DLL and a list of all the functions exported by the DLL. You'll need to provide it to the linker when you build a program that uses the DLL so it knows that an external identifier is actually a function exported by the DLL. The linker uses the import library to add entries to the import table for the EXE. Which is then in turn used by Windows at runtime to figure out what DLLs need to be loaded to run the program.

这篇关于DLL 和 LIB 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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