Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of static libraries used in an executable

People also ask

Where are static libraries stored?

Static libraries belong next to their corresponding dynamic libraries, and in accordance with the FHS. Keep in mind that static libraries are usually only needed to build software, not run it. Show activity on this post.

What command can be used to list the symbols stored in a static library?

If we want to see the contents of our library, we can use the ar option -t . We can also see the symbols in our library, using the command nm , which lists each symbol's symbol value, symbol type, and symbol name from object files.

Which command shows all shared libraries required by a binary executable or another shared library?

Using the ldd Command The syntax to use this command is pretty straight forward: ldd [option]... file... The ldd command is pretty handy to list the shared libraries of a program.

Can a DLL link to static library?

When your DLL refers to an external content (like function or variable), it is resolved at linking time - together with all dependencies. But that's all. If your static library has a function named print_sample_string() , but your DLL does not use it, it won't be attached to DLL image.


ldd <exe filename> shows dynamically linked libraries

nm <exe filename> shows the symbols in the file.

To see which symbols come from static libraries requires running nm against those libraries to get a list of the symbols (functions, etc.) in them, then comparing them to what your list of symbols from nm <exe filename>.

You compare lists with the comm command. See man comm for details.

This was taken from this forum here.


No, the names of the libraries are discarded during the linking process. However, if your executable contains debug information (i.e. it was compiled with the -g flag), you may be able to get information from that.


If you have the source code and don't want to go through all the code for this, you can generate map file while compiling to know which static libraries are linked.

For example g++ -Xlinker -Map=a.map main.c, check the map file for linked static library information.


Unless a given compiler stores some sort of meta data inside the binary then, no. A static library is code that is directly compiled into the binary.