简体   繁体   English

如何查找c ++库(.lib)中的类?

[英]how to find classes present in a c++ library (.lib)?

what tool can I use to find classes present in a C++ static library (.lib) ? 我可以用什么工具来查找C ++静态库(.lib)中的类? This information is for building a library in one solution and use it in another solution by giving lib as input to linker. 此信息用于在一个解决方案中构建库,并通过将lib作为链接器的输入在另一个解决方案中使用它。 As the lib can come from 3rd parties, its difficult to find what services it is offering. 由于lib可以来自第三方,因此很难找到它提供的服务。

Usually from the documentation and headers. 通常来自文档和标题。 If you don't have that, you could use dumpbin -exports or dumpbin -symbols on it to get a list of exported functions (mostly, -symbols for static librarys, -exports for a link library for a DLL). 如果你没有这样的,你可以使用dumpbin -exportsdumpbin -symbols上获得的导出的函数列表(主要是, -symbols静态图书馆的, -exports的链接库DLL中)。

If the code was written in (Microsoft) C++, and the public names are mangled, that can tell you quite a bit (return types, parameter types). 如果代码是用(Microsoft)C ++编写的,并且公共名称被破坏了,那可以告诉你很多(返回类型,参数类型)。 If they're basically C functions (either from a C compiler, or a C++ compiler but marked with extern "C" ), the names won't be mangled, so it won't be able to tell you nearly as much (just names, nothing about the type or even number of parameters). 如果它们基本上是C函数(无论是来自C编译器,还是C ++编译器,但标有extern "C" ),名称不会被破坏,所以它几乎不能告诉你(只是名称,参数类型甚至数量都没有。

If it's a third party library you usually need at least header files (usually .h ) that will contain class declarations with its corresponding members. 如果它是第三方库,您通常至少需要包含类声明及其相应成员的头文件(通常为.h )。 You will use that header file to compile your code and then link with the compiled library. 您将使用该头文件来编译代码,然后链接到已编译的库。

There is no standard way of getting that information from the compiled binary. 从编译的二进制文件中获取该信息没有标准方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM