Subject: Re: COFF shared libraries
To: Vadim Vygonets <vadik@cs.huji.ac.il>
From: Todd Vierling <tv@wasabisystems.com>
List: port-sh3
Date: 01/25/2001 18:08:18
On Fri, 26 Jan 2001, Vadim Vygonets wrote:

: I patched Exim (http://www.exim.org/) to make eximon (Exim
: monitor, an X11 frontend) compile on NetBSD systems that use ELF
: binary format.  It involved distinguishing between a.out and ELF
: binary formats in the build process.

BTW, the preferred method for this detection is to pass __ELF__ through the
preprocessor and see if it is still __ELF__ (meaning *non*-ELF system).
i.e.

  if echo __ELF__ | ${CC} -E - | grep -q __ELF__; then
    # a.out system
  else
    # ELF system
  fi

: Do NetBSD ports that use COFF binary formats have shared
: libraries?

The only platform that uses COFF as the standard binary format (sh3) will be
switching to ELF soon.  But to answer your question, "no."

: If I want to link a program that uses X11 on such systems
: (assuming they have X11 libraries), is the -R flag to gcc needed
: (as it is on ELF), or is -L enough?

The proper flag to ensure that the compile will work on all platforms and
versions of the compiler is:

  cc ... -Wl,-R/usr/X11R6/lib/ -L/usr/X11R6/lib -lXwhatever

The -Wl,-R... option will add -R to the ld command line--note the trailing
slash.  There are dozens of other combinations, but this one is guaranteed
to work on all NetBSD systems and versions with shared library support.
(It will probably work, and be ignored, on static binary systems too.)

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --  http://www.wasabisystems.com/