*BSD News Article 95227


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.netspace.net.au!news.mel.connect.com.au!munnari.OZ.AU!uunet!in3.uu.net!192.239.17.140!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!howland.erols.net!vixen.cso.uiuc.edu!uchinews!condor.cns.iit.edu!usenet
From: HOVOEDW@minna.cns.iit.edu (Ed Hovorka)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Help: Shared Libs
Date: 13 May 1997 14:51:17 GMT
Organization: Illinois Institute of Technology, Academic Computing.
Lines: 38
Distribution: world
Message-ID: <5l9v55$97l@condor.cns.iit.edu>
References: <5k5s03$f38$1@nnrp.cs.ubc.ca> <5k7kj8$cv2$2@sol.ctr.columbia.edu>
NNTP-Posting-Host: harpo.cns.iit.edu
X-News-Reader: VMS NEWS v1.25
In-Reply-To: wpaul@ctr.columbia.edu's message of 30 Apr 1997 14:22:32 GMT
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:40796

In <5k7kj8$cv2$2@sol.ctr.columbia.edu> wpaul@ctr.columbia.edu writes:

> Daring to challenge the will of the almighty Leviam00se, Henry Avatar Chan
> (q8e192@ugrad.cs.ubc.ca) had the courage to say:
> 
> : Suppose I have a whole bunch of .o (object) files.
> : How do I make a .so (shared dynamic lib) out of them?
> 
> If the .o files were compiled with -fpic, then you can make a shared
> lib out of them with ld -Bshareable (see the ld(1) man page for more
> details).
> 
> : Do these .o files have to be compiled with -fPIC?
> 
> Yes they do. No, you can't convert the objects from one format to the other.
> 
> : Any full examples of creating shared libs are appreciated.
> 
> You can easily do it with a simple Makefile. Say you have two source
> files, foo.c and bar.c, that you want to turn into a shared library
> called 'libtest.so.1.0'. Create a Makefile like this:
> 
Can anyone help me?

I am able to build a shared lib, but when I try to use it I have problems.
I am able to call dlopen() and it loads successfully.  But, when I call dlsym()
to load a function, it fails by returning 0, and dlerror() returns a null
string. (errno is also not being set).  Are there any special command line
options I need when compiling my main program (the one that dynamically
loads my .so)?

The same code runs fine on other Unix platforms.  I'm running FreeBSD
2.2.1-R.  Thanks,


| Ed Hovorka // hovoedw@harpo.acc.iit.edu // Illinois Institute of Technology
|                                          Chicago, IL
| Moving at the speed of life.