Sun linker help needed

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Oct 30 08:00:28 AEST 1988


In article <1862 at loral.UUCP> jlh at loral.UUCP (Physically Pffft) writes:
>I'm trying to migrate our bloody HUGE application from a Vax to a Sun.
>My problem is that fflush and fclose got re-written somewhere down the
>line.  On the Vax the linker just links in the new routines with no
>problem, but on the Sun the linker aborts with a 'symbol multiply defined'
>error.  It seems as though I have to have these new routines for the code
>to run, and being rather lazy I don't want to go in and re-name all
>the fclose and fflush calls we use.  So my question is, how do I link this
>stuff?  I was under the impression that the linker only searched libraries
>for unresolved symbols, if this was true it would never notice the duplicates
>in the libc library.  Any advice, Doug or Chuq?

The problem is that some unresolved symbol (probably used by other stdio
routines) lives in the same object module that defines the official
fclose/fflush entries, so when the needed symbol is linked in, along
come the unwanted duplicates.  The simplest attempt at a solution is to
add "-Dfflush=XXXfflush -Dfclose=XXXfclose" to the CFLAGS in your Makefile.
However, if anything in the C library functions linked with your code
wants fflush or fclose it will use the official version, not the XXX*
version.  Much worse is the likelihood that whatever the XXX* versions
do is not correct for the particular C library stdio implementation.
To really solve this right you need to find out what the code is
attempting to do then design a correct replacement for its current
approach.  You may find it advisable to add support for fflush((FILE*)0)
to the standard C library, although until there are enough ANSI C
conforming implementations using that feature will restrict the
application's portability.

Also be sure to fire the original programmer while you're at it.



More information about the Comp.unix.questions mailing list