Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Apr 2002 09:57:47 +0300
From:      Peter Pentchev <roam@ringlet.net>
To:        "M. Warner Losh" <imp@village.org>
Cc:        dima@sinp.msu.ru, freebsd-hackers@FreeBSD.ORG
Subject:   Re: dynamic libraries
Message-ID:  <20020413095747.E352@straylight.oblivion.bg>
In-Reply-To: <20020413.004859.00083529.imp@village.org>; from imp@village.org on Sat, Apr 13, 2002 at 12:48:59AM -0600
References:  <Pine.BSF.4.43.0204121308470.4449-100000@BigKing.sinp.msu.ru> <20020412.220916.34608052.imp@village.org> <20020413092834.A352@straylight.oblivion.bg> <20020413.004859.00083529.imp@village.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--8vCeF2GUdMpe9ZbK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Apr 13, 2002 at 12:48:59AM -0600, M. Warner Losh wrote:
> In message: <20020413092834.A352@straylight.oblivion.bg>
>             Peter Pentchev <roam@ringlet.net> writes:
> : On Fri, Apr 12, 2002 at 10:09:16PM -0600, M. Warner Losh wrote:
> : > In message: <Pine.BSF.4.43.0204121308470.4449-100000@BigKing.sinp.msu=
.ru>
> : >             Dmitry Mottl <dima@sinp.msu.ru> writes:
> : > : How can I link C program with different versions of the same librar=
y?
> : >=20
> : > You can't.
> :=20
> : 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 thin=
k,
> : the original poster clarifies he wants to do, for no specific reason)?
>=20
> 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
=2E/foo18:
        libncurses.so.5 =3D> /usr/lib/libncurses.so.5 (0x28065000)
        libncurses.so.3 =3D> /usr/lib/compat/libncurses.so.3 (0x280a7000)
        libc.so.4 =3D> /usr/lib/libc.so.4 (0x280b8000)
        libmytinfo.so.2 =3D> /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..

> : If it is the first, well, it stands to reason :)  If it is the first
> : thing and the first thing only, then how do you do the second thing?
> : (insert flashbacks from "Analyze This" as appropriate)
>=20
> I don't know.  I don't think that's possible, but I'm less sure short
> of giving the entire path name to the .so file or playing symbolic
> link games.

Yep, thanks for that hint; specifying full path names works :)

G'luck,
Peter

--=20
Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I am the thought you are now thinking.

--8vCeF2GUdMpe9ZbK
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjy31usACgkQ7Ri2jRYZRVMF9QCeL7+/h6avpw04W/H8et985wa6
OMoAnRQ+NIc40iALNKj7G2ruGaUuPN+0
=X6Tx
-----END PGP SIGNATURE-----

--8vCeF2GUdMpe9ZbK--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020413095747.E352>