same function name in multiple archives - bad idea?

Patrick Mahan PMahan at
Tue Feb 1 18:21:46 UTC 2011

> -----Original Message-----
> From: owner-freebsd-questions at [mailto:owner-freebsd-
> questions at] On Behalf Of Anton Shterenlikht
> Sent: Tuesday, February 01, 2011 9:08 AM
> To: freebsd-questions at
> Subject: same function name in multiple archives - bad idea?
> Is it wrong to have functions with the same name
> in multiple archives? E.g:
> % ar -t /usr/local/lib/libslatec.a | grep fdump.o
> fdump.o
> % ar -t /usr/local/lib/libcmlib.a | grep fdump.o
> fdump.o
> Which "fdump" function will be used if I then link
> against -larchive1.a -larchive2.a?
> And is there an easy way to find functions belonging
> in multiple archives?


I believe for ELF images the linker will stop looking after finding it, so the
order of -l<library> controls which one will be used.  If you want to see which
one was used during linking, use the ld options '-M -Map <mapfile> --cref' which
will create a map file with cross references.


More information about the freebsd-questions mailing list