Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does compiler use lib file?

I am curious about how c/c++ compiler analyse lib files ? I mean say I create a library containing some classes, I am using that library in my main program. How does compiler know what class names are there in that library. Of course that information is present in binary format, I want to use that functionality in my program, to be specific I have a binary lib file and I want to know all classes and properties/functions present in that lib file.

Is it possible ? If compiler can do that why can't some library ?

thanks for any clue

like image 415
Xinus Avatar asked Feb 27 '23 06:02

Xinus


1 Answers

The compiler doesn't do what you are suggesting, but the linker does.

The compiler knows the information it needs from the header files that are included relating to the lib files.

The linker then puts together the declarations you are including and the lib file along with its other object files.

It is probably possible to get the information from the .lib file by decompiling it for example, but this is a lot of work and probably not what you're looking to do.

like image 107
Brian R. Bondy Avatar answered Mar 07 '23 12:03

Brian R. Bondy