Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 May 2000 15:29:12 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        "Brian J. McGovern" <mcgovern@spoon.beta.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: Accessing [non dynamic] symbols in shared library/_init and _fini
Message-ID:  <20000518152912.F21508@fw.wintelcom.net>
In-Reply-To: <200005182051.QAA82814@spoon.beta.com>; from mcgovern@spoon.beta.com on Thu, May 18, 2000 at 04:51:25PM -0400
References:  <200005182051.QAA82814@spoon.beta.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Brian J. McGovern <mcgovern@spoon.beta.com> [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




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