Loads a dynamic link library (DLL)
f = package.loadlib (libraryname, funcname)
Loads the dynamic library (DLL), and tries to find the entrypoint named "funcname".
On success returns the function funcname.
On failure returns nil plus 2 error messages.
The error might be "The specified module could not be found." if the DLL is not found. You may also get this message if the DLL is dependant on another DLL and that other DLL cannot be found. Use a "dependency checker" to see what DLLs the target DLL might require. If you are certain that the DLL you are requesting exists, then the problem is probably a dependency.
The error might be "The specified procedure could not be found." if the function is not found in the DLL. You may also get this message if the DLL is dependant on another DLL and some entry points in that other DLL cannot be found. Use a "dependency checker" to see whether all required entry points have been resolved. If you are certain that the entry point that you are requesting exists in the target DLL, then the problem is probably a dependency from the target DLL to another DLL.
You would normally then execute the function (as in the example below) to get it to install the Lua functions into the script space.
f = assert (package.loadlib ("luacom.dll", "luacom_openlib"))
f () -- execute function: luacom_openlib
Or, more briefly:
assert (package.loadlib ("luacom.dll", "luacom_openlib")) ()
See Also ...
package.config - Package configuration string
package.cpath - Search path used for loading DLLs using the "require" function
package.loaded - Table of loaded packages
package.loaders - Table of package loaders
package.path - Search path used for loading Lua code using the "require" function
package.preload - A table of special function loaders
package.seeall - Sets a metatable for the module so it can see global variables
Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua LPEG library
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua string functions
Lua table functions
Scripting callbacks - plugins
(Help topic: lua=package.loadlib)