Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: Failing to link with a QPE client -- any hints?
Home

[Freeciv-Dev] Re: Failing to link with a QPE client -- any hints?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Failing to link with a QPE client -- any hints?
From: Marko Lindqvist <marko.lindqvist@xxxxxxxxxxx>
Date: Thu, 22 Apr 2004 01:54:29 +0300

Jason Dorje Short wrote:

It's a problem in the linking stage.

I've run into this before, and I don't know why it happens. The order of the list of .a files seems to matter, so one .a file must come before another so that its functions may be used by that object file (or perhaps vice versa). You can see I don't really understand the problem :-).

The workaround is generally to list these .a files twice. This is already done for some .a files, but not all (this is done for civserver as well as civclient).

 ...

Perhaps someone can find some documentation on this somewhere? How is it supposed to be done?


I don't have any documentation to the matter handy, but this is gcc feature (not bug, I remember reading this some years back from some mailing list where gcc maintainers claimed it to be intentional, or at very least accepted side effect of great concept). While linking static libraries, it does not collect all symbols, but only those it already knows it needs. So, if library A is linked before B, and all calls to certain function in A is from B, it is not collected. When we give A second time after B, symbol is collected - and it may depend on some not-yet-collected symbol in B... I have worked with project where all libraries had to be given four! times. Well, probably it could have been avoided by carefully reorganizing their order, but as there were lots of small libraries it was easier to just make it "$(PROG_LIBS) $(PROG_LIBS) $(PROG_LIBS) $(PROG_LIBS)"...

While I'm at it, I'll mention another related problem I had hard time tracking time a while back. For certain project above mentioned 'list libraries twice' trick did not work in new environment. I found out that new versions of libtool require option '--preserve-dup-deps' or linking is performaed as if libraries were give only once. To make it worse, older versions of libtool, where this work by default, have no such option at all, so one can't just blindly use it. Actually I found that this behaviour differs between libtool 'versions' with exactly same version number. So it's time to implement some configure checks. But hey, this is not actually freeciv related as libtool is not used here at all. I forgot.


 - Caz



[Prev in Thread] Current Thread [Next in Thread]