Oron Peled <o...@actcom.co.il> writes:

> On Wednesday 10 July 2013 21:31:51 Diego Iastrubni wrote:
>> 
>> My program needs liba, which in turn needs libb.. which in turn needs libk.
>> The last libk needs symbols from liba.. and this is where it gets funky.
>> While linking g++ complains that symbols are missing ... and from ar+nm I
>> see that those symbols are avarilable on liba.
>
> * Omer Zak correctly replied that this circular dependency represent
>    bad design of the libraries authors.
>
> * But don't despair yet...

I think there is yet another option that may help in certain cases - I
have not used it for a while and I am writing from memory, which may be
faulty. Check the docs, try, test. There may be a symbol (or a few) in
your libk - or even earlier in the cycle - that will be unresolved
without another pass at liba, but your program may not need this symbol
at all. In such a case you can add "-u <symbol>" or
"--undefined=<symbol>" to the ld command (or pass from gcc) to keep the
symbol unresolved in the executable. If it is never used - who cares?
You may repeat the option for multiple symbols.
 
At the risk of repetition - but I think it can't be emphasized enough:
if these (at least liba and libk) are your in-house libraries do what
you can to force your co-workers/managers/etc. to figure out what should
properly go into each of them and redesign.  What you see is a symptom
of not enough thought invested in modelling the domain problem or proper
modularization of functionality or both. This will likely bite your team
in the future in more serious ways than this. So deal with it early.

-- 
Oleg Goldshmidt | p...@goldshmidt.org

_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to