package.loadlib
Lua function

package.loadlib

Summary

Loads a dynamic link library (DLL)

Prototype

f = package.loadlib (libraryname, funcname)



Description

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 ...

Topics

DOC_lua_base Lua base functions
DOC_lua_bc Lua bc (big number) functions
DOC_lua_bit Lua bit manipulation functions
DOC_lua_coroutines Lua coroutine functions
DOC_lua_debug Lua debug functions
DOC_lua_io Lua io functions
DOC_lua_math Lua math functions
DOC_lua_os Lua os functions
DOC_lua_package Lua package functions
DOC_lua_rex Lua PCRE regular expression functions
DOC_lua Lua script extensions
DOC_lua_string Lua string functions
DOC_lua_tables Lua table functions
DOC_lua_utils Lua utilities
DOC_scripting Scripting

Lua functions

LUA_package.config package.config (Package configuration string)
LUA_package.cpath package.cpath (Search path used for loading DLLs using the "require" function)
LUA_package.loaded package.loaded (Table of loaded packages)
LUA_package.loaders package.loaders (Table of package loaders)
LUA_package.path package.path (Search path used for loading Lua code using the "require" function)
LUA_package.preload package.preload (A table of special function loaders)
LUA_package.seeall package.seeall (Sets a metatable for the module so it can see global variables)

(Help topic: lua=package.loadlib)

DOC_contents Documentation contents page