dynamic/shared libraries (again)

BlitzMax Forums/BlitzMax Beginners Area/dynamic/shared libraries (again)

Jim Teeuwen(Posted 2009) [#1]
hello people.

I've been trolling the forums and google about this for 2 days, but there doesn't seem to be a proper solution to this yet.

My problem is loading dll/so libraries at runtime. I know the pub.win32 module has some functions to do this on windows, but obviously they won't work on linux/macos. Is there a module out there which provides the loadLibraryA/W and GetProcAddress functionality for linux/macos?


jkrankie(Posted 2009) [#2]
On macos the equivalent to a .dll is called a dylib. severaly of Brucey's modules use them, so you could look at the source to those for some pointers.

Cheers
Charlie


N(Posted 2009) [#3]
You want dlopen, dlsym, and dlclose (see man pages) for Linux and Mac OS. For Mac OS, you'll just use the 'dylib' extension instead of the usual 'so'.

More info on dynamic libraries in Mac OS:
http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/DynamicLibraries/000-Introduction/Introduction.html


Jim Teeuwen(Posted 2009) [#4]
great. thanks!


Flemmonk(Posted 2009) [#5]
Better yet if you have a cross-platform library already compiled for each platform you likely have a .lib file which you can declare:
'?Win32
Import "newton.lib"
Import "jointlibrary.lib"
'?

?MacOS
Import "newton32.a"
?

?Linux
Import "newton.a"
?

Extern

' Functions here...

EndExtern


And be sure to supply the appropriate compiled versions.


N(Posted 2009) [#6]
Based on what I've heard, he doesn't.