From owner-freebsd-hackers Sat Apr 13 0: 1:31 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id 183A937B686 for ; Sat, 13 Apr 2002 00:00:37 -0700 (PDT) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.11.3/8.11.3) with ESMTP id g3D70Zi18787; Sat, 13 Apr 2002 01:00:35 -0600 (MDT) (envelope-from imp@village.org) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.11.6/8.11.6) with ESMTP id g3D70Zc56404; Sat, 13 Apr 2002 01:00:35 -0600 (MDT) (envelope-from imp@village.org) Date: Sat, 13 Apr 2002 01:00:34 -0600 (MDT) Message-Id: <20020413.010034.64370390.imp@village.org> To: roam@ringlet.net Cc: dima@sinp.msu.ru, freebsd-hackers@FreeBSD.ORG Subject: Re: dynamic libraries From: "M. Warner Losh" In-Reply-To: <20020413095747.E352@straylight.oblivion.bg> References: <20020413092834.A352@straylight.oblivion.bg> <20020413.004859.00083529.imp@village.org> <20020413095747.E352@straylight.oblivion.bg> X-Mailer: Mew version 2.1 on Emacs 21.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message: <20020413095747.E352@straylight.oblivion.bg> Peter Pentchev writes: : On Sat, Apr 13, 2002 at 12:48:59AM -0600, M. Warner Losh wrote: : > In message: <20020413092834.A352@straylight.oblivion.bg> : > Peter Pentchev writes: : > : On Fri, Apr 12, 2002 at 10:09:16PM -0600, M. Warner Losh wrote: : > : > In message: : > : > Dmitry Mottl writes: : > : > : How can I link C program with different versions of the same library? : > : > : > : > You can't. : > : : > : Okay; what exactly is it that you cannot do - link a program against : > : two versions of the same library simultaneously (I thought so), or : > : link a program against a *specified* version of a library (what, I think, : > : the original poster clarifies he wants to do, for no specific reason)? : > : > You can't, generally, link against two different versions of the same : > library. The reason is that you get mutiply defined symbols because : > it is very very very rare that two different versions of the same : > library wouldn't have any symbols that overlap. : : Well, actually, your 'full path' suggestion gave me an idea.. : : [roam@straylight:p6 ~/c/misc/foo]$ cc -o foo18 foo18.c /usr/lib/libncurses.so.5 /usr/lib/compat/libncurses.so.3 : [roam@straylight:p6 ~/c/misc/foo]$ ldd ./foo18 : ./foo18: : libncurses.so.5 => /usr/lib/libncurses.so.5 (0x28065000) : libncurses.so.3 => /usr/lib/compat/libncurses.so.3 (0x280a7000) : libc.so.4 => /usr/lib/libc.so.4 (0x280b8000) : libmytinfo.so.2 => /usr/lib/compat/libmytinfo.so.2 (0x28151000) : [roam@straylight:p6 ~/c/misc/foo]$ : : Duplicate symbols are not a problem - AFAIK, symbols are resolved : in the order the libraries were specified on the linker command line, : and, consequently, in the order the dependencies are recorded into : the resulting executable file. So, if foo18 calls an ncurses.5 routine, : it will be invoked from ncurses.5; if foo18 calls a routine that is : not present in ncurses.5, it will be invoked from ncurses.3. : : So it is actually possible; not that I have ANY idea what the point : would be.. Ah, this just hides the problem of incompatible interfaces :-(. that's why the libraries have different version numbers: they have a different API. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message