41

I've long used cygwin's nm command for all my .lib symbol debugging needs, but recently I thought about referring to it in a SO answer and realized that most Windows developers don't have cygwin installed.

So what is the Microsoft equivalent to nm, i.e., what command will list the symbols exported by a .lib file, the undefined symbols in the .lib, and so forth?

For the curious, a sample nm man page is here.

pnuts
  • 58,317
  • 11
  • 87
  • 139
David Norman
  • 19,396
  • 12
  • 64
  • 54

3 Answers3

39

Try dumpbin.exe.

MSDN dumpbin.exe reference.

user7610
  • 25,267
  • 15
  • 124
  • 150
Tim
  • 20,184
  • 24
  • 117
  • 214
  • 1
    both links are dead :-( – dothebart Jul 03 '18 at 13:47
  • yes, got it working. However, the MSDN documentation is next to worthless - a properly implemented `--help` argument could have superseeded it easily – dothebart Jul 05 '18 at 11:27
  • Microsoft has three levels of support - primary support, advanced support, and technical support. These can be summed up with three phrases: 1) No one has ever reported an issue like that before; 2) Why would you ever want to do that?; and 3) I'm-pissed-I've-got-to-talk-to-actual-users-so-I'm-going-to-talk-real-fast-and-spout-code-like-a-fountain-and-you'd-better-get-it-all-down-the-first-time-because-I-will-NOT-repeat-myself. – Bob Jarvis - Слава Україні Nov 26 '18 at 12:16
7
  1. Run vcvarsall.bat which might present in your installed path of Microsoft Visual Studio. This sets environmental variable required for dumpbin.exe.

    D:>"D:\Program Files (x86)\Microsoft Visual Studio 10.0\vcvarsall.bat" x86

  2. Then use dumpbin.exe. For example dumpbin.exe /ALL <bin_file> gives all symbols.

Community
  • 1
  • 1
rashok
  • 12,790
  • 16
  • 88
  • 100
0

The nm command provides -C option, which shows demangled names. There is c++filt in Linux/MacOSX, provide nearly the same as -C for nm.

On Windows, there is dumpbin.exe, which is like nm on Linux. There is also undname on Windows, which is like c++filt on Linux: (https://learn.microsoft.com/en-us/cpp/build/reference/decorated-names?view=msvc-170)

C:\>undname ?func1@a@@AAEXH@Z
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation. All rights reserved.

Undecoration of :- "?func1@a@@AAEXH@Z"
is :- "private: void __thiscall a::func1(int)"

You may also need vswhere to locate where dumpbin.exe and undname.exe located.

ChrisZZ
  • 1,521
  • 2
  • 17
  • 24