Contents of a static library

Prasoon Saurav picture Prasoon Saurav · Sep 21, 2010 · Viewed 60.2k times · Source

I have a static library, say mystaticlib.a. I want to see its contents, such as the number of object files inside it.

How can I do this on gcc?

Answer

Prasoon Saurav picture Prasoon Saurav · Sep 21, 2010

On gcc, use ar -t.

-t option of the gnu archiver (ar) writes a table of contents of archive to the standard output. Only the files specified by the file operands shall be included in the written list. If no file operands are specified, all files in archive shall be included in the order of the archive.

More info here.