-1

I have a library and I want to get all mangled function and variable names. I will put those names in a .def file to import them in another project. I'm programming in c++ using Vs2019, how can I get the function names for my .def file? I've thousand of functions and variables and I need a process to get them automatically

ADD. The dumpbin /archivemembers seems not work, it's possible retrieve the list of mangled names after the build of the library? Where are those names?

jerloi
  • 11
  • 5
  • Related: [https://stackoverflow.com/questions/31410284/list-functions-in-lib-on-windows](https://stackoverflow.com/questions/31410284/list-functions-in-lib-on-windows) – drescherjm Aug 25 '22 at 14:54
  • This answer seemed to work for a static library: [https://stackoverflow.com/a/42167904/487892](https://stackoverflow.com/a/42167904/487892) – drescherjm Aug 25 '22 at 15:19
  • Are you using static library or dynamic library? – Minxin Yu - MSFT Aug 26 '22 at 01:41

1 Answers1

2

Answered here: How to See the Contents of Windows library (*.lib)

You can run either of these commands at the Developer command prompt:

dumpbin /archivemembers foo.lib

or

lib /list foo.lib

which will give you a full list of symbols in your library.

However maintaining this def file is quite tedious, and exporting all symbols is probably inadvisable. I suggest you look at the alternative method of using __declspec(dllexport) to selectively export symbols from a DLL. You can define a macro which exports while building the DLL itself, and imports when building client code. By tagging the classes and functions in this way, each time you build, the exports will be regenerated and there is no separate .def file to maintain.

gavinb
  • 19,278
  • 3
  • 45
  • 60