如何列出C/C ++静态库的依赖项? [英] How to list dependencies of c/c++ static library?

查看:848
本文介绍了如何列出C/C ++静态库的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于静态库(.a文件),如何列出它的模块级依赖关系?

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

我知道对于共享库(.so),我们可以使用 objdump readelf 来做到这一点:

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

objdump -p test.so

readelf -d test.so

我可以得到

需要libOne.so

NEEDED libOne.so

需要libc.so.6

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

我会得到类似的东西:

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

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

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

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

00000000 DF UND 00000000 QFileInfo :: fileName()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.

这篇关于如何列出C/C ++静态库的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆