loadlib - dynamic library loading facilities for the Lua language.
Download it here (tar gzipped, 7474 bytes).
It was tested on AIX 3/4, Linux, IRIX 5, SunOS 4/5, Windows 95/NT.
It was not tested for HP-UX and Next.
The tar file includes the dlfcn emulation library for AIX written by Jens-Uwe Mager.
To use loadlib, call the initialization function
This function registers three Lua functions:
loadlib( libname, [dir] ) -> libhandle, [errormsg]
Loads a library. libname can be a full path to the library or just the library name. If it is a library name, dir can be used to specify the directory where the library is. The function returns a libhandle to be used with the functions
callfromlib. If the library cannot be loaded, the function returns nil as the libhandle and a string describing the error.
loadlib( "/usr/lib/libX11.so" )
loadlib( "c:\\lua\\poslua.dll" )
loadlib( "poslua" ): search for libposlua.so in unix or poslua.dll in windows, using the system default search path
loadlib( "poslua", "/lua/" ): search for /lua/libposlua.so in unix, /lua/poslib.dll in windows
unloadlib( libhandle )
Unload the library libhandle. libhandle must be an userdata returned by the function
Warning: the Lua functions eventually registered by the library are not removed!
callfromlib( libhandle, functionname )
Call the function functionname from the library libhandle. libhandle must be an userdata returned by the function
loadlib. functionname must be a string.
Typically, you use
callfromlibonly once, after
loadlib, to call an open function that will register the lib functions in the Lua environment.