[Discuss] Compiling a binary
pw
p.willis at telus.net
Wed Sep 27 18:38:58 PDT 2006
Alan W. Irwin wrote:
>
> * Be careful of the order in which static libraries are mentioned on the
> link line. Linkers proceed down the list of libraries in a serial manner,
> and if any library has symbols resolved by some library previous to it in
> the list, then you will have to mention that previous library later in the
> list as well.
>
> * Even so, when I went through this exercise (making a statically linked
> application) recently, there were still plenty of unresolved symbols
> (mostly
> involving X-related libraries). There is probably a better way, but I found
> I had to do several hours worth of google searching for the symbols to find
> the associated library name I had to add to the link. It was not at all
> clear that I was going to win the battle until the last undefined symbol
> finally disappeared after a good guess on my part. Mass use of nm could be
> your friend here, but unfortunately most/all Linux distros strip symbols
> from their installed libraries.
>
> * As Peter alluded to, the link command warned about plug-ins that were
> dlopened by various libraries. As I recall there were also plug-in
> warnings
> when I ran the executable, but I seemed to get away with it, and the
> executable actually worked.
I was thinking about this a few weeks ago for other reasons.
My thought was to create a script that uses ldd ,and possibly nm
or objdump (binutils) to collect all the dependencies for you.
The files would go into a directory local to your build and then
the script would organise and generate the link line for your
compiler. You would then just recompile the application using the
additional flags.
Peter
More information about the Discuss
mailing list