Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!sun-spots-request From: auspex!guy@uunet.uu.net (Guy Harris) Newsgroups: comp.sys.sun Subject: Re: Dynamic linking on SunOS 4.x Keywords: SunOS Message-ID: <6005@brazos.Rice.edu> Date: 22 Mar 90 19:15:25 GMT Sender: news@rice.edu Organization: Sun-Spots Lines: 39 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n96 X-Sun-Spots-Digest: Volume 9, Issue 93, message 3 >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.