From owner-freebsd-hackers Sun Dec 7 03:20:15 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id DAA04228 for hackers-outgoing; Sun, 7 Dec 1997 03:20:15 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id DAA04221; Sun, 7 Dec 1997 03:20:05 -0800 (PST) (envelope-from dfr@nlsystems.com) Received: from herring.nlsystems.com (herring.nlsystems.com [10.0.0.2]) by nlsystems.com (8.8.5/8.8.5) with SMTP id LAA05153; Sun, 7 Dec 1997 11:18:57 GMT Date: Sun, 7 Dec 1997 11:18:57 +0000 (GMT) From: Doug Rabson To: John Birrell cc: Nate Williams , 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? In-Reply-To: <199712070015.LAA01594@freebsd1.cimlogic.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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