Yes, it must have an initialization function into it that receives a lua_State* and returns an integer. When you use loadlib like this:But when you say about the use of loadlib() function, does the file.dll need to be prepared to load 'add-on' lua functions?
-- Lua code func, error = loadlib("my_library.dll", "my_library_init")You're actually telling Lua to search for a function called "my_library_init" into "my_library.dll". loadlib() returns it so you can call it from Lua (if something fails nil plus an error string is returned):
if func then func() else print("error loading library: " .. error) endFor more information on how to make modules read http://lua-users.org/wiki/BinaryModuleTutorial (in this example Lua 4.0 is used, but in version 5 it's nearly the same thing).
You could compile a module into a static library and directly link it against the Lua interpreter (like the standard Lua library, for example) so it's always available without needing the DLL. But loading DLLs is more flexible and there's no need to modify the source of the Lua interpreter. As you might guess LuaCheia (and other similar Lua distributions like LuaX) use DLLs so they're modular.So, do I need to compile luacom like a file.dll, just to use it?
-ap
Attachment:
PGP.sig
Description: Mensaje firmado digitalmente