I have an application, and a static library. The library appears to build just fine - it certainly compiles my foo
and bar
and geewhizz
functions just fine, and creates the static library without any errors or warnings.
However, when the application builds and links to the static library, it manages to link to functions foo
and bar
but cannot find function geewhizz
. How can I tell if geewhizz
made it into the library? I can't see any /map
option for libraries like there is for building the applications. And it is pointless using the \map
option when building the application, because it can't find my geewhizz
function, and has no basis to report on it.
I am working with a mixture of C and C++, and I suspect there is probably a function name mangling/translation issue, or calling convention issue, that is causing the problem, so I think having a list of the functions included in the library should be able to shine light on that. But if there is any more general advice for resolving such issues, I'd be pleased to hear it.
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.
The sample projects in this article were created using Visual Studio 2010. A static library consists of object files that are linked together with an exe file. Object files are the output of compilers of unmanaged code and consists of functions that can only be used by unmanaged code.
Thanks to helpful comments from @indiv and @WhozCraig in particular, you have at least these two options:
/LIST
option in Visual Studio's linker program (lib.exe
)dumpbin
utility with the /linkermember
optionVisual studio is not exactly helpful in making the /LIST
option easy to use. You will have to specify it as an additional option on the Command Line, but how to do that is not clear. /LIST
on its own produces a listing to standard output, but neither specifying a file nor using the >
redirection operator work in any obvious way. In fact, I've given up trying to work out how to make this option work at all.
Thankfully, dumpbin
is a utility shipped with Visual Studio (even the Express versions) and is well documented here. So until someone makes /LIST
remotely workable to ordinary people, use dumpbin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With