Dynamic linking on SunOS 4.x
Guy Harris
auspex!guy at uunet.uu.net
Fri Mar 23 05:15:25 AEST 1990
>What mechanisms do I have available to me under SunOS for this?
It depends on what version of SunOS you're talking about.
If you're talking about 4.0[.x], you don't have a lot; you'd have to roll
your own, and I don't think you'll be able to get much help from the
run-time loader. (Rob, do you have more cheerful news for him?)
If you're talking about 4.1, you have:
"dlopen()", which takes the name of a ".so" file as an argument, maps that
".so" file into your address space and links it in to your program, and
returns a "handle" to it; and get back a "handle" on it;
"dlsym()", which takes a "handle" from "dlopen()" and a character string
which is the name of a function in the ".so" file referred to by the
handle, and returns a pointer to the function that you can use to call it
(after converting it from "void *" to the appropriate function type);
"dlclose()", which takes a handle from "dlopen()" and decrements the
reference count on the ".so" file, unmapping it if it goes to zero;
and one other function whose name I can't remember.
(If you're talking about System V Release 4, you will have those same four
functions, at least on 99 44/100% of the platforms it's on.)
Unfortunately, none of this helps you if you don't have 4.1, and it's not
released yet, so neither you nor most other people have it....
>I thought shared libraries (.so) were the answer, but I have been unable
>to create a shared library. There seems to be no documentation on
>*creating* a shared library, only documentation on using one after it
>exists.
Again, not that it'd help a lot in your current situation, but check out
the "Shared Libraries" section of the "Programming Utilities and
Libraries" part of the SunOS 4.0[.x] documentation - it discusses, among
other things, how to build a shared library.
More information about the Comp.sys.sun
mailing list