omatai
omatai

Reputation: 3728

How to find which functions are in a static c/c++ library in Visual Studio

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.

Upvotes: 6

Views: 3946

Answers (1)

omatai
omatai

Reputation: 3728

Thanks to helpful comments from @indiv and @WhozCraig in particular, you have at least these two options:

  • Use the /LIST option in Visual Studio's linker program (lib.exe)
  • Use the dumpbin utility with the /linkermember option

Visual 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.

Upvotes: 6

Related Questions