<p>I have an inherited project that uses a build script (not make) to build and link the project with various libraries.</p>

<p>When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming from.</p>

<p>The script is compiling and linking with GNU tools.</p>

[{'answer_id': 47805, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 0, 'selected': False, 'text': '<p>Static libraries, that makes life more difficult in this regard. In case of dynamic libraries you could just have used ldd on the resulting executable and be done with it. The best bet would be some kind of configuration file. Alternatively you could try to look for -l arguments to gcc/ld. Those are used to specify libraries. You could write a script for extracting it from the output, though I suspect that you will have to do it manually because by the time you know what the script should look for you probably already know the answer.</p>\n'}, {'answer_id': 47807, 'author': 'Xavier Nodet', 'author_id': 4177, 'author_profile': 'https://Stackoverflow.com/users/4177', 'pm_score': 0, 'selected': False, 'text': '<p>It is probably possible to do something useful using e.g. Perl, but you would have to provide more details.  On the other hand, it could be easier to simply analyze the script... </p>\n'}, {'answer_id': 47809, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 1, 'selected': False, 'text': "<p>You might try using the <code>nm</code> tool.  Given the right options, it will look at a binary (archive or linked image) and tell you what objects were linked into it.</p>\n\n<p>Actually, here's a one-liner I use at work:</p>\n\n<pre><code>#!/bin/sh\n\nnm -Ag $* | sed 's/^.*\\/\\(.*\\.a\\):/\\1/' | sort -k 3 | grep -v ' U '\n</code></pre>\n\n<p>to find the culprits for undefined symbols.  Just chop off the last grep expression and it should pretty much give you what you want.</p>\n"}]
['https://Stackoverflow.com/questions/47780', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/445087/']