Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate header file (*.h) for on shared library file (*.so)

Tags:

c

linux

gcc

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?

like image 799
dzav Avatar asked Apr 24 '13 16:04

dzav


People also ask

How do you create a header file?

To make a header file, we have to create one file with a name, and extension should be (*. h). In that function there will be no main() function. In that file, we can put some variables, some functions etc.

What is the header of a file library?

Header Files: The files that tell the compiler how to call some functionality (without knowing how the functionality actually works) are called header files. They contain the function prototypes. They also contain Data types and constants used with the libraries. We use #include to use these header files in programs.

Does DLL include header files?

Like any other well-behaved (i.e., actually usable) DLL, your DLL must supply a set of public interface header files. Under normal circumstances, you must have all these public interface header files available for building a program using that DLL.

What does shared library contain?

A shared library or shared object is a file that is intended to be shared by multiple programs. Symbols used by a program are loaded from shared libraries into memory at load time or runtime.


1 Answers

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.

like image 195
urzeit Avatar answered Oct 03 '22 18:10

urzeit