How can I generate a list of symbols used by a build product from a particular statically linked library?
Say I have a visual studio project that builds a windows exe or dll from c++ source.
The project statically links to several library (.lib) files.
I would like to generate the subset of the available functionality in a particular .lib that the project actually links to.
A very crude way to achieve this would be to remove the .lib from the linker input list. The error list on the build would then show me all the symbols that could not be found.
Is there a better/proper way to generate this list, I'm happy with a solution that can be run as a custom build step in the project or one that runs against a built binary.
I've looked at both the linker and dumpbin com开发者_如何学Cmand line options but have not seen anything appropriate.
Two ways I can think of to do it in Visual Studio (2005):
Add /VERBOSE to linker options, or via GUI under project property pages -> Linker -> General -> Show Progress = "Display All Progress Messages". The linker then outputs which functions it links from which libs.
Add /MAP:mymapfile.map to linker options, or via GUI under project property pages -> Linker -> Debugging -> Generate Map File and Map File Name. This produces a text file of symbols and which libs they were linked from.
Does that give you what you need?
You could try to use the nm utility from gnu binutils to list the symbols of a .lib file.
精彩评论