228

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 ?

Something similar to emfar and elfdump utilities (on Linux systems) ?

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
Nick Borodulin
  • 3,065
  • 4
  • 21
  • 21
  • 1
    Note: The command prompt specific to .NET comes with the Visual Studio editions but not with the Express edition. From: https://social.msdn.microsoft.com/Forums/en-US/9f4b8961-63eb-4062-bf3c-12f0126f0e80/how-to-get-visual-studio-command-prompt?forum=Vsexpressvb – isgoed Dec 30 '14 at 12:48

8 Answers8

237

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.

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.

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.

Craig M. Brandenburg
  • 3,354
  • 5
  • 25
  • 37
Tim Lesher
  • 6,341
  • 2
  • 28
  • 42
  • 10
    Both /SYMBOLS and /EXPORTS don't work nowadays. I have to use /ALL with a |more pipe to see all functions in the .lib file. – user5280911 Jun 21 '18 at 10:44
  • 10
    @user5280911 `dumpbin /symbols` worked fine for me today on Win 10 with VS 2019 developer command prompt on a static library `.lib` file, why do you say it doesn't work these days? – Jake Cobb Jul 27 '20 at 20:14
  • 3
    You can use `/OUT:filename` in order to export the output to a file – psq Oct 07 '20 at 12:35
  • 1
    What is DUMPBIN ? Where is it ? – Sandburg Feb 15 '22 at 13:06
  • 1
    Dumpbin is a command line app that's installed alongside VS. From within VS you can access it via Tools > Command Line > Developer Command Prompt. Then type "dumpbin" – Ben Oct 17 '22 at 21:08
  • `dumpbin /exports` does not show `__imp__calloc` in `ucrt.lib` for example (although the reference arises in user code), `dumpbin /linkermember:1` does show it ... Hint: Use `| find /i "calloc"` to filter the symbols you search for. – MattTT Jun 15 '23 at 13:20
135

Open a Visual Studio Command Prompt

dumpbin /ARCHIVEMEMBERS openssl.x86.lib

or

lib /LIST openssl.x86.lib

or just open it with 7-zip :) its an AR archive

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Tanguy
  • 2,227
  • 1
  • 18
  • 8
22

I wanted a tool like ar t libfile.a in unix.
The windows equivalent is lib.exe /list libfile.lib.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
lgwest
  • 1,347
  • 5
  • 16
  • 26
20

"dumpbin -exports" works for dll, but sometimes may not work for lib. For lib we can use "dumpbin -linkermember" or just "dumpbin -linkermember:1".

Frank
  • 505
  • 5
  • 14
16

LIB.EXE is the librarian for VS

http://msdn.microsoft.com/en-us/library/7ykb2k5f(VS.80).aspx

(like libtool on Unix)

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
15

DUMPBIN /EXPORTS Will get most of that information and hitting MSDN will get the rest.

Get one of the Visual Studio packages; C++

user7610
  • 25,267
  • 15
  • 124
  • 150
jim
  • 1,502
  • 12
  • 23
5

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.

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

Searching the Static keyword using one of these tools seems to be a good hint.

4

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.

2) Enter the following command:

dumpbin /EXPORTS my_lib_name.lib

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50