Subject: netgrent is broken [[was: Problem building rdist: fails to link on
To: None <port-pmax@netbsd.org>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 12/10/1994 21:17:01
I wrote:
>rdist fails to link due to multiple definitions of the symbol
>``_warn'':
>    cc   -o rdist gram.o docmd.o expand.o lookup.o main.o server.o -lcompat
>    err.o(.text+0x1b0): multiple definition of `_warn'
>    main.o(.text+0x88c): first defined here
>
>
>As far as I can guess, a cycle in libc.a is causing the linker
>to include err.o in its output.  err.o is compiled from err.c,

It turns out that the problem is this: A reference to innetgr is
causing the linker to pull in getnetgrent.o.  getnetgrent.o is, in
turn, references warnx().  To resolve that reference. the linker is
pulling in err.o from libc.a.  err.o defines its own, non-weak version
of ``warn()'', causing a multiple definition, due to the definition of
``warn()'' in rdist/main.c.

In summary, it's src/lib/libc/gen/getnetgrent.c that's broken.  I
don't think it's correct for library functions refer to warn() or
warnx(), because applications may legitimately define their own
versions of warnx() or warn().

--Jonathan