bagebb bagebb - 4 months ago 24
Linux Question

How to list dependencies of c/c++ static library?

For a static library (.a file), how to list the module-level dependencies of it?

I know for a shared library (.so), we can use objdump or readelf to do this:

objdump -p


readelf -d

I can get something like



But for a static library, I can only get the dependencies in symbol-level, for example, by running

objdump -T test.a

I will get some thing like:

00000000 DF UND 00000000 QByteArray::mid(int, int) const

00000000 DF UND 00000000 QUrl::fromEncoded(QByteArray const&)

00000000 DF UND 00000000 QFileInfo::fileName() const

But I need the information in module-level, does anyone know how to get that information?


A static library have no such list of dependencies.

A static library is nothing more than an archive of object files. And as object files doesn't know what libraries they depend on, neither can a static library.