[Home] [Downloads] [Search] [Help/forum]

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

Lua functions

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

Topics

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 syntax
Lua table functions
Lua utilities
Scripting
Scripting callbacks - plugins

(Help topic: lua=package.loadlib)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]