*BSD News Article 49496


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!howland.reston.ans.net!agate!reason.cdrom.com!usenet
From: "Jordan K. Hubbard" <jkh@FreeBSD.org>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Bug in 2.0.5's dlopen() functionality
Date: 28 Aug 1995 09:41:27 GMT
Organization: Walnut Creek CDROM
Lines: 25
Message-ID: <41s307$rfn@reason.cdrom.com>
References: <87pwhri1b7.fsf@hrothgar.mindspring.com>
NNTP-Posting-Host: time.cdrom.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (X11; I; FreeBSD 2.2-CURRENT i386)
To: rsanders@mindspring.com
X-URL: news:87pwhri1b7.fsf@hrothgar.mindspring.com

Robert Sanders <rsanders@mindspring.com> wrote:
>ldd doesn't work on non-executable .so files, but here's how I created
>the .so file:
>
>$ make tkintermodule.so
>ld -Bshareable  tkintermodule.o  -L/usr/X11R6/lib -L/usr/local/lib \
>   -ltk40 -ltcl74 -lX11 -o tkintermodule.so

That won't work.  You need to explicitly dlopen() the dependency libs
from the _init() routine of tkintermodule.so in order to get it to pull
in shared libraries not actually bound to the main executable.

>When I call a tkintermodule procedure that calls TCL/Tk/X11
>procedures, the program crashes.  So, it seems that something doesn't
>work quite right with "chained" dynamic linking.

Well, to be more explicit, the "chained dynamic linking" simply doesn't
work in that case.  You need to do it explicitly.  Sort of a pain, but
at least you can do it!

Use the constructor hook (_init()) that dlopen() calls to register the
depends and you should be fine.

						Jordan