Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Dec 1997 11:18:57 +0000 (GMT)
From:      Doug Rabson <dfr@nlsystems.com>
To:        John Birrell <jb@freebsd1.cimlogic.com.au>
Cc:        Nate Williams <nate@mt.sri.com>, tlambert@primenet.com, jkh@time.cdrom.com, mike@smith.net.au, hsu@freebsd.org, hackers@hub.freebsd.org
Subject:   Re: shared library with static Motif?
Message-ID:  <Pine.BSF.3.95q.971207111531.1629B-100000@herring.nlsystems.com>
In-Reply-To: <199712070015.LAA01594@freebsd1.cimlogic.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 7 Dec 1997, John Birrell wrote:

> Nate Williams wrote:
> > But, aside from legalities the real issue hasn't been answered.  Is it
> > *technically* possible to link in a 'static' library into a 'shared'
> > library so that the end-user doesn't need a Motif library to get access
> > to the shared library?
> 
> Yes (I think 8-). You still use ld -Bshareable so that you get a shared
> object, but you list the Motif static libraries with the objects that you
> link into your shared library. The linker (should) then resolve all Motif
> references in your shared library, leaving the X11 ones as external
> references to the X shared libraries.
> 
> Just don't use the -l option to search for libraries because ld will
> try to translate these to shared libraries. Use an explicit reference
> like /usr/lib/X11/libXm.a

The problem with linking a dynamic library with a static one is that the
object files in the static lib will not normally be compiled with -fpic
and so the resulting shared object will have a lot of text relocations.
This will still work but will not share particularly well since the
runtime linker will have to write into the text section to fix the text
relocations.   The normal solution to this is to have a static lib
containing PIC objects (e.g. /usr/lib/libc_pic.a).

--
Doug Rabson				Mail:  dfr@nlsystems.com
Nonlinear Systems Ltd.			Phone: +44 181 951 1891
					Fax:   +44 181 381 1039




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.971207111531.1629B-100000>