Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!sun-spots-request From: mdbs!jon@ee.ecn.purdue.edu (Jon Reid) Newsgroups: comp.sys.sun Subject: Dynamic linking on SunOS 4.x Keywords: Miscellaneous Message-ID: <5986@brazos.Rice.edu> Date: 21 Mar 90 21:08:36 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 48 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 9, Issue 96, message 1 I am looking for information on how to do "dynamic linking" under SunOS. Our 4GL products have a "load function" facility to load a user-written C function into memory and execute it, like so: load function "myfunc" ! load user-written function from disk ! into already-executing program. output myfunc(a,b,c) ! execute user-written C function ! as if it were a built-in function. Under all systems, the user writes a C function which follows our special conventions for getting arguments from and returning a value to the 4GL. Under OS/2, the user C function is linked into a a dynamic-link library (.DLL file) which we load using the DosLoadModule call. Under MSDOS, the user C function is linked with a library that includes dummy main() routine to make the linker make an executable file; the .exe is then loaded using the Terminate-And-Stay-Resident mechanism. Once in memory, our 4GL can determine what routines are in the loaded .exe and branch to them as needed. Under VMS, we create a shared image which is loaded dynamically using the LIB$FIND_IMAGE_SYMBOL routine. What mechanisms do I have available to me under SunOS for this? 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. Am I missing some documentation? The cc.1v source file for the man page has references to a -sharedlib flag which are commented out? The SUG (Sun User Group) tape apparently has an example of loading an object file into an already-executing program. This might be the answer, but the user-written C program might need to be linked with other libraries. If anyone out there has dealt with this problem before and would be willing to share your techniques with me, please drop me a note. If anyone has the SUG load-an-object-file example and could send it to me, I would appreciate that also. If I'm simply missing some essential documentation, please point out what I'm missing. Thanks for listening: Jon Reid UUCP: uunet!purdue!mdbs!jon mdbs, Inc. -- KG Software Division P.O. Box 5268 (Two Executive Dr.) Disclaimer: I speak for me Lafayette, IN 47903 Quote: "Your plan worked, Muad'dib!"