为共享库文件(* .so)生成头文件(* .h) [英] Generate header file (*.h) for on shared library file (*.so)

查看:1231
本文介绍了为共享库文件(* .so)生成头文件(* .h)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有共享库文件( libmylib.so ),但没有头文件( mylib.h )你知道一些方法/工具从共享库文件生成这个头文件吗?

解决方案

这通常是不可能的,因为.so文件没有包含关于参数列表的足够信息 - 特别是在使用非标准类型(结构体,例如)时,因为类型信息是不是.so文件的一部分。



即使只使用标准类型,参数列表也不是ELF符号表的一部分(参见 http://refspecs.linuxbase.org/elf/elf.pdf 1-15ff。)。



但是,如果库没有被剥离(=它包含调试信息),那么DWARF部分确实包含有关参数列表的信息,请参阅如何从elf文件中提取函数原型?获取详细信息。


I have shared library file (libmylib.so), but have no header file (mylib.h) for it.

Do you know some ways/tools to generate this header file from shared library file?

解决方案

This is impossible in general, since the .so file does not contain enough information about the parameter lists - especially if non-standard types (structs, e.g.) are being used, since type information is not part of the .so file.

Even if only standard types are used, the argument list is not part of the ELF symbol table (see http://refspecs.linuxbase.org/elf/elf.pdf 1-15ff.).

However, if the library is not stripped (= it contains debugging information), the DWARF-part does contain information about parameter lists, see How to extract function prototypes from an elf file? for details.

这篇关于为共享库文件(* .so)生成头文件(* .h)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆