Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msunews!agate!newsxfer.itd.umich.edu!gatech!news.sprintlink.net!matlock.mindspring.com!usenet From: rsanders@interbev.mindspring.com (Robert Sanders) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Dynloading and FBSD2.? Date: 06 Jun 1995 11:30:07 -0400 Organization: /usr/lib/news/organization Lines: 30 Message-ID: <87zqjv4ghs.fsf@interbev.mindspring.com> References: <3qn4eq$7m5@shore.shore.net> <3qngvu$aet@news.nynexst.com> <3qve99$ioq@helena.MT.net> <87sppopmr7.fsf@interbev.mindspring.com> <3r1o18$pks@shore.shore.net> NNTP-Posting-Host: interbev.mindspring.com In-reply-to: witr@rwwa.com's message of 6 Jun 1995 14:17:12 GMT X-Newsreader: (ding) Gnus v0.82 On 6 Jun 1995 14:17:12 GMT, witr@rwwa.com (Robert Withrow) said: > But I would sure like to know how I am *supposed* to do it on > FBSD 2.0R, cause it ain't in the docs, and there ain't a .h file > for it... I don't have a 2.0R system around, but 'man dlopen' on 2.0.5A gave a pretty good description. link(5) and ld(1) are also useful pages to examine. FreeBSD's dynamic loading interface is almost identical to the one you'd use on SunOS. I think the magic procedure for creating a shared library looks a bit like this (I've only done it under Linux): gcc -fpic -c foo.c ld -Bshareable -o libfoo.so.1 foo.o You can then link against libfoo with -lfoo just as you would against any other library. In addition, you can use dlopen() to access its symbols at runtime. If you want real-life examples of building shared libraries, check out the FreeBSD /usr/lib source tree on an archive near you. Under Linux, you have to specify a "-rdynamic" flag to gcc for executables that were going to use the dl*() routines. That forced to keep all the executable's externally visible symbols listed in the ELF symtab. I'm not sure what the equivalent is -- if there is any -- under FreeBSD. -- Robert