bagebb
bagebb

Reputation: 221

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?

Upvotes: 20

Views: 30467

Answers (2)

digitalTrilunaire
digitalTrilunaire

Reputation: 105

@Some programmer dude is right, but what you can do is build a simple program using this library statically and then check with ldd -v what are the dependencies.

Upvotes: 3

Some programmer dude
Some programmer dude

Reputation: 409442

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.

Upvotes: 26

Related Questions