I have a bunch of .a
files whose generation process is not controlled by me, nor are their sources. When I use them for linking, I want to know their dependencies (libA.a
depends on libB.a
if there is some symbol undefined in libA.a
but defined in libB.a
), so that I can put them in the correct order in the ld
/gcc
command line.
I don't want to do over linking (i.e. specify those libraries twice), because I want to persist those dependencies into BUILD
file of bazel, so I want to know the precise dependency.
I wonder if there is some command line tool, given libA.a
and libB.a
, can tell whether libA.a
depends on libB.a
? If there is not such, how do I write such a script?
Note: my definition for dependency may not be 100% accurate. Let me know if there are other types of dependency other than defined/undefined symbols.
The simplest way is to process the output of nm libA.a
and nm libB.a
and look for U
symbols, but there are many types of symbols listed in man nm
, each of them have different semantic, so I am concerned I might miss some if I use such simplified approach.