dllLib, need code for Beos, MacOs and others

hi`

Jess wrote:

this is part of a little library im putting together to allow programs
to handle loading of shared libraries and doing other system specific
things having to do with plugins. There is currently code for
unix(linux, solaris and others) and Windows (not tested but should
work). This is going to be used by another library and program i am

are you aware of libltdl?–
Daniel Vogel My opinions may have changed,
666 @ http://grafzahl.de but not the fact that I am right

sory this is a little off topic but in its own twisted way its SDL
related.

this is part of a little library im putting together to allow programs
to handle loading of shared libraries and doing other system specific
things having to do with plugins. There is currently code for
unix(linux, solaris and others) and Windows (not tested but should
work). This is going to be used by another library and program i am
making and if i can get people to add suport for the other os’s SDL
suports (macos, beos) my library should be able to run on everything
SDLdoes. This is just something i quickly threw together so it could
still use some improvement, please send me any changes you make. You are
free to use this code in anyway you like (it aint much so why would i
care). okay enough of my rambling.

Jess

-------------- next part --------------
The purpose of this library is to provide a portable method for
dynamically loading plugins and libraries.

The folowing interface may be subject to change in future versions as
this is something i quickly threw together for use by another library im
working on and will be modified to suit its needs. (although the main
functions shouldnt change much)

DLL_Load:
Loads a library, takes a a filename as an argument and returns
a handle of the type LIB_HANDLE. If this filename is not an absolute path
it is not guaranteed what locations will be searched as it depends on the
system. If a DLL_Load is called on a library more than once it is not
loaded again, the reference count is incremented and the same handle is
returned as before.

DLL_Unload:
Decrements the reference count of a library and unloads it if it
drops to zero.

DLL_GetSym:
Returns a pointer to the symbol requested. A symbol can be a
function or a variable in the library loaded by DLL_Load.

Error Handling
Each of the above functions returns NULL on error.

sample code(modified dlopen manpage sample code to use this library):

          #include "dllLib.h"

          int main(int argc, char **argv) {
              LIB_HANDLE handle = DLL_Load("libm");
              double (*cosine)(double) = DLL_GetSym(handle, "cos");
              printf ("%f\n", (*cosine)(2.0));
              DLL_Unload(handle);
          }

-------------- next part --------------
A non-text attachment was scrubbed…
Name: dllLib.tgz
Type: application/octet-stream
Size: 1591 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20000204/1089ba97/attachment.obj

Jess wrote:

this is part of a little library im putting together to allow programs
to handle loading of shared libraries and doing other system specific
things having to do with plugins. There is currently code for
unix(linux, solaris and others) and Windows (not tested but should
work). This is going to be used by another library and program i am
making and if i can get people to add suport for the other os’s SDL
suports (macos, beos) my library should be able to run on everything
SDLdoes. This is just something i quickly threw together so it could
still use some improvement, please send me any changes you make. You are
free to use this code in anyway you like (it aint much so why would i
care). okay enough of my rambling.

Basically, this is a portable layer for dlopen/LoadLibrary
functionality, as it seems. I have two things to say about this:

1- I think this is such a widely available feature (I think only DOS
doesn’t have it, even MacOS has this) and so simple that maybe it should
be made part of SDL. Some OpenGL-using programs use that to load and
unload various OpenGL drivers. You could look at Mozilla’s NSPR for an
example of doing this on a very large array of platforms.

http://lxr.mozilla.org/nspr/source/nsprpub/pr/src/linking/prlink.c

2- If you think that you would like to work on what is the next level
for this stuff, take a look at XPLC (cross-platform lightweight
components).

http://xplc.sourceforge.net/

BTW, don’t freak out on the mention of the primary language being C++, I
really intend on having C bindings, but I want it to be simple to use
and workable, so I’m deferring this work until it works nice in C++.

Also, there may seem to be very little code at the moment, but you
should know that mostly all of this has already been implemented in a
proof of concept prototype (that was internal to Ludus Design) that we
knew we’d scrap and start over cleanly. This is the clean start over.–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/

Daniel Vogel wrote:

this is part of a little library im putting together to allow programs
to handle loading of shared libraries and doing other system specific
things having to do with plugins. There is currently code for
unix(linux, solaris and others) and Windows (not tested but should
work). This is going to be used by another library and program i am

are you aware of libltdl?

Where can I find it? I looked on freshmeat, to no avail…–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/

Basically, this is a portable layer for dlopen/LoadLibrary
functionality, as it seems.

Also, if you look in older versions of SDL, I had the same functionality
for Linux, Win32, BeOS, and MacOS. I dropped it when I no longer dynamically
loaded SDL, but the code is still there and might be useful to add again at
some point.

From experience though, you can run into some hairy debugging issues on Linux.
I hacked a special version of gdb that understands dll unloading.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Pierre Phaneuf wrote:

Daniel Vogel wrote:

this is part of a little library im putting together to allow programs
to handle loading of shared libraries and doing other system specific
things having to do with plugins. There is currently code for
unix(linux, solaris and others) and Windows (not tested but should
work). This is going to be used by another library and program i am

are you aware of libltdl?

Where can I find it? I looked on freshmeat, to no avail…

it is part of libtool

from the README (actually that was the whole README ;))

“This is GNU libltdl, a system independent dlopen wrapper for GNU
libtool.”–
Daniel Vogel My opinions may have changed,
666 @ http://grafzahl.de but not the fact that I am right

Daniel Vogel wrote:

Where can I find it? I looked on freshmeat, to no avail…

it is part of libtool

from the README (actually that was the whole README ;))

“This is GNU libltdl, a system independent dlopen wrapper for GNU
libtool.”

Oh yeah, but libtool isn’t very popular yet with Windows developers,
much less with BeOS or MacOS developers…

It does look nice, it even has a way of simulating dynamically loading
stuff that is actually statically linked! :-)–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/