When compiling a program with static libraries, it was suggested to me from many sources (including SO community) to include the library twice.
As in:
gcc main.c -lslA -lslB -lslC -lslA -lslB -o final
Does this result in a bigger executable (.i.e. is the linker smart enough to avoid double inclusion?).
Is this (multiple inclusion) the proper solution or a workaround (.i.e. will there always exist a more proper, even if harder way to handle it)
undefined references
in the other linked libraries .i.e. why does ordering matter.-lA -lB
, the linker goes like this: process A, forget it for good, process B. If B depends on A, and the relevant symbols were not already pulled, the link will fail. Including a library multiple times is a way to cope with circular dependencies.--start/end-group
is another (GNU-specific) way. It's better to not have any in the first place though.