From owner-freebsd-questions Thu May 18 14:56:21 2000 Delivered-To: freebsd-questions@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 8E60A37BD65 for ; Thu, 18 May 2000 14:56:18 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e4IMTDC03659; Thu, 18 May 2000 15:29:13 -0700 (PDT) Date: Thu, 18 May 2000 15:29:12 -0700 From: Alfred Perlstein To: "Brian J. McGovern" Cc: questions@FreeBSD.ORG Subject: Re: Accessing [non dynamic] symbols in shared library/_init and _fini Message-ID: <20000518152912.F21508@fw.wintelcom.net> References: <200005182051.QAA82814@spoon.beta.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <200005182051.QAA82814@spoon.beta.com>; from mcgovern@spoon.beta.com on Thu, May 18, 2000 at 04:51:25PM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Brian J. McGovern [000518 15:06] wrote: > I've just starting playing with dlopen() and family. So far, I've got it > opening up libraries and using the functions contained therein. > > The functions in the dynamic library use stdio routines, such as printf() > without problems. > > The issue, simply, is that I'm clueless about the mechanics. The next thing > I'd like to do is be able to call a function thats not shared, but linked > in to the main program. This comes back as an undefined symbol. > > Secondly, i'm currently compiling the libraries simply as: > cc -shared -o foo.so foo.c > > It there anything I should add/change/etc? > > Also, I've been reading a few of the man pages, and it seems that ld handles > calling _init and _fini at program startup and shutdown. I was curious if > something similar is automatically done for shared libraries that are loaded? > I'd like to have some initialization done without having to poke the user > of the library to have to do it. Suggestions? You'll need to link with -export-dynamic for your main program's symbols to be visible. For shared libraries initilization at link time you'll have to look harder, I found it once but I can't remeber how to do it. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message