构建DLL文件时,生成的LIB文件是否包含DLL名称? [英] When building a DLL file, does the generated LIB file contain the DLL name?

查看:22
本文介绍了构建DLL文件时,生成的LIB文件是否包含DLL名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual C++ 中,当我构建一个 dll 时,输出文件是 .dll 和 .lib.

In Visual C++ , when I build a dll , the output files are .dll and .lib.

是 .lib 文件中内置的 dll 的名称.

Is the name of the dll built into the .lib file .

我问这个问题的原因是:当我通过导入这个 dll 构建我的 exe 并运行 exe 时,exe 会尝试定位 dll 以将其加载到进程地址空间中.

The reasson I ask this question is : When I built my exe by importing this dll and run the exe , the exe tries to locate the dll to load it in the process address space .

由于我们只是在项目属性中指定库名称(.lib 文件),exe 是如何知道 dll 的名称的.

As we just specify the library name (.lib file) in the project properties , how does the exe get to know the name of the dll .

注意:我转储了库文件 (.lib),发现它不包含 dll 的名称.

Note : I dumpbin libary file (.lib) and saw that it does not contain the name of the dll .

推荐答案

LIB文件变成EXE中的导入表.这确实包含 DLL 的名称.

The LIB file is turned into an import table in the EXE. This does contain the name of the DLL.

如果您运行 dumpbin/all MyDLL.lib,您可以看到这一点.请注意,dumpbin MyDll.lib 本身并没有显示任何有用的信息:您应该使用 /all.

You can see this if you run dumpbin /all MyDLL.lib. Note that dumpbin MyDll.lib by itself doesn't show anything useful: you should use /all.

这显示了 .LIB 文件中定义的所有部分.您可以忽略任何 .debug 部分,因为它们不会出现在发布版本中.在 .LIB 文件中,有一组 .idata 节.在我刚刚构建的 DLL 项目中,LIB 文件包含一个 .idata$4 部分,该部分定义了要放入 EXE 的导入表中的符号,包括 DLL 名称:

This shows all of the sections defined in the .LIB file. You can ignore any .debug sections, because they wouldn't be present in a Release build. In the .LIB file, there are a collection of .idata sections. In the DLL project that I just built, the LIB file contains a .idata$4 section which defines the symbols to be put in the EXE's import table, including the DLL name:

Archive member name at 83E: MyDll.dll/      
497C3B9F time/date Sun Jan 25 10:14:55 2009
         uid
         gid
       0 mode
      2E size
correct header end

  Version      : 0
  Machine      : 14C (x86)
  TimeDateStamp: 497C3B9F Sun Jan 25 10:14:55 2009
  SizeOfData   : 0000001A
  DLL name     : MyDll.dll
  Symbol name  : ?fnMyDll@@YAHXZ (int __cdecl fnMyDll(void))
  Type         : code
  Name type    : name
  Hint         : 2
  Name         : ?fnMyDll@@YAHXZ

这篇关于构建DLL文件时,生成的LIB文件是否包含DLL名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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