Skip to content
Advertisement

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 test.so

or

readelf -d test.so

I can get something like

NEEDED libOne.so

NEEDED libc.so.6

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?

Advertisement

Answer

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.

Advertisement