如何查看 Windows 库 (*.lib) 的内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/305287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to See the Contents of Windows library (*.lib)
提问by Nick Borodulin
I have a binary file - Windows static library (*.lib).
Is there a simple way to find out names of the functions and their interface from that library ?
我有一个二进制文件 - Windows 静态库 (*.lib)。
有没有一种简单的方法可以从该库中找出函数的名称及其接口?
Something similar to emfar
and elfdump
utilities (on Linux systems) ?
类似于emfar
和elfdump
实用程序(在 Linux 系统上)?
回答by Tim Lesher
Assuming you're talking about a static library, DUMPBIN /SYMBOLS
shows the functions and data objects in the library. If you're talking about an import library (a .lib
used to refer to symbols exported from a DLL), then you want DUMPBIN /EXPORTS
.
假设您在谈论静态库,DUMPBIN /SYMBOLS
显示库中的函数和数据对象。如果您在谈论导入库(.lib
用于指代从 DLL 导出的符号),那么您需要DUMPBIN /EXPORTS
.
Note that for functions linked with the "C" binary interface, this still won't get you return values, parameters, or calling convention. That information isn't encoded in the .lib
at all; you have to know that ahead of time (via prototypes in header files, for example) in order to call them correctly.
请注意,对于与“C”二进制接口链接的函数,这仍然不会让您返回值、参数或调用约定。该信息根本没有编码.lib
;您必须提前知道(例如通过头文件中的原型)才能正确调用它们。
For functions linked with the C++ binary interface, the calling convention and arguments are encoded in the exported name of the function (also called "name mangling"). DUMPBIN /SYMBOLS
will show you both the "mangled" function name as well as the decoded set of parameters.
对于与 C++ 二进制接口链接的函数,调用约定和参数在函数的导出名称中进行编码(也称为“名称修改”)。 DUMPBIN /SYMBOLS
将向您显示“损坏的”函数名称以及解码后的参数集。
回答by Tanguy
Open a visual command console (Visual Studio Command Prompt)
打开可视化命令控制台(Visual Studio 命令提示符)
dumpbin /ARCHIVEMEMBERS openssl.x86.lib
or
或者
lib /LIST openssl.x86.lib
or just open it with 7-zip:) its an AR archive
或者直接用 7-zip 打开它:) 它是一个 AR 存档
回答by lgwest
I wanted a tool like ar t libfile.a
in unix.
The windows equivalent is lib.exe /list libfile.lib
.
我想要一个像ar t libfile.a
unix一样的工具。
Windows 等效项是lib.exe /list libfile.lib
.
回答by Frank
"dumpbin -exports" works for dll, but sometimes may not work for lib. For lib we can use "dumpbin -linkermember" or just "dumpbin -linkermember:1".
“dumpbin -exports”适用于 dll,但有时可能不适用于 lib。对于 lib,我们可以使用“dumpbin -linkermember”或“dumpbin -linkermember:1”。
回答by jim
回答by Lou Franco
LIB.EXE is the librarian for VS
LIB.EXE 是 VS 的图书管理员
http://msdn.microsoft.com/en-us/library/7ykb2k5f(VS.80).aspx
http://msdn.microsoft.com/en-us/library/7ykb2k5f(VS.80).aspx
(like libtool on Unix)
(如 Unix 上的 libtool)
回答by user3292568
1) Open a Developer Command Prompt for VS 2017 (or whatever version you have on your machine)(It should be located under: Start menu --> All programs --> Visual Studio 2017 (or whatever version you have on your machine) --> Visual Studio Tools --> Developer Command Prompt for VS 2017.
1) 打开 VS 2017(或您机器上的任何版本)的开发人员命令提示符(它应位于:开始菜单 --> 所有程序 --> Visual Studio 2017(或您机器上的任何版本) --> Visual Studio 工具 --> VS 2017 的开发人员命令提示符。
2) Enter the following command:
2)输入以下命令:
dumpbin /EXPORTS my_lib_name.lib
dumpbin /EXPORTS my_lib_name.lib
回答by Hilton Fernandes
Like it can be seen in other answers you'll have to open a Developer Command Prompt offered in your version of Visual Studio to have dumpbin.exe
in your execution path. Otherwise, you can set the necessary environment variables by hand.
就像在其他答案中可以看到的一样,您必须打开 Visual Studio 版本中提供的开发人员命令提示符才能dumpbin.exe
在执行路径中使用。否则,您可以手动设置必要的环境变量。
dumpbin /EXPORTS yourlibrary.lib
will usually show just a tiny list of symbols. In many cases, it won't show the functions the library exports.
dumpbin /EXPORTS yourlibrary.lib
通常只会显示一小部分符号。在许多情况下,它不会显示库导出的函数。
dumpbin /SYMBOLS /EXPORTS yourlibrary.lib
will show that symbols, but also an incredibly huge amount of other symbos. So, you got to filter them, possibly with a pipe to findstr
(if you want a MS-Windows tool), or grep
.
dumpbin /SYMBOLS /EXPORTS yourlibrary.lib
将显示这些符号,但也会显示数量惊人的其他符号。因此,您必须过滤它们,可能使用管道findstr
(如果您需要 MS-Windows 工具)或grep
.
Searching the Static
keyword using one of these tools seems to be a good hint.
Static
使用这些工具之一搜索关键字似乎是一个很好的提示。