Get list of static libraries used in an executable Get list of static libraries used in an executable c c

Get list of static libraries used in an executable


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.