Tools for inspecting .lib files?

前端 未结 5 1422
梦毁少年i
梦毁少年i 2020-11-30 21:50

I\'m evaluating some underdocumented software. When I build a sample project, I\'m getting a linker error that looks like:

error LNK2019: unresolved external symbo         


        
5条回答
  •  隐瞒了意图╮
    2020-11-30 22:12

    First of all you need to know which type of library you are looking at. Some libraries simply contain linkages for a DLL (i.e., import libraries) and others are code objects that become part of the executable image (i.e., static libraries). From the looks of that output, you were looking at a DLL import library.

    Next you want to use the right tool. Lib.exe is used to extract object files from libraries and what-not. This is pretty much the same as the jar utility for Java. Microsoft provides dumpbin.exe which will dump information from the library. I see that LarryF already mentioned this.

    For import libraries, run dumpbin.exe -headers foo.lib and redirect it to an output file. The output will contain snippets for each symbol that the related DLL exports. Search for lines starting with " Symbol name :". Note that there are two spaces before and after "Symbol name" if you want an exact match. You can also run the output through findstr to generate a list of symbols and redirect that to a text file if you want something a little nicer to look at:

    dumpbin.exe -headers foo.lib | findstr /c:"  Symbol name  :" > foo-exports.txt
    

    The other option is to open the related DLL with depends.exe.

提交回复
热议问题