[En-Nut-Discussion] Circular references in libraries

Bernard Fouché bernard.fouche at kuantic.com
Mon Oct 10 10:23:20 CEST 2005


Henrik Maier wrote:

> The current approach of separating Nut/OS into separate libraries 
> leads to unavoidable circular references between the different libraries.
>
> Often several libraries have to be listed twice or more in order to 
> resolve the circular references. I find it always a kind of a gamble 
> to find the best order to list libraries.
>
> To avoid this wouldn't it be better to create a monolithic library for 
> Nut/OS, e.g. libnutall.a ?
>
> Henrik
> _______________________________________________
>
Which compiler/linker are you using? Usually a linker will fill 
undefined symbols from a library, remembering what was defined in this 
library even if it was unused. So the order is important only when you 
have two or more definitions for the same function in different 
librairies: the linker will use the first it encounters.

Now if you are using gcc (for instance) you may have collisions between 
avr-libc and functions from NutOs having the same name (for instance 
'printf'), which is a different problem than function ordering. If so, 
in the linker invocation, place all references to NutOs libs before 
asking for '-lc' (ask it explicitly)

  Bernard



More information about the En-Nut-Discussion mailing list