lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


That what I have in linit.c (and works for 5.3):
 
static const luaL_Reg loadedlibs[] = {
  {"_G", luaopen_base},
  {LUA_LOADLIBNAME, luaopen_package},
  {LUA_COLIBNAME, luaopen_coroutine},
  {LUA_TABLIBNAME, luaopen_table},
  {LUA_IOLIBNAME, luaopen_io},
  {LUA_OSLIBNAME, luaopen_os},
  {LUA_STRLIBNAME, luaopen_string},
  {LUA_MATHLIBNAME, luaopen_math},
  {LUA_UTF8LIBNAME, luaopen_utf8},
  {LUA_DBLIBNAME, luaopen_debug},
#if defined(LUA_COMPAT_BITLIB)
  {LUA_BITLIBNAME, luaopen_bit32},
#endif
  {LUA_LFSLIBNAME, luaopen_lfs},
  {LUA_SQLITE3LIBNAME, luaopen_lsqlite3},
  {NULL, NULL}
};
 
 
Should it be different for v5.4?
 
Sent: Wednesday, May 13, 2020 11:42 PM
Subject: Re: Lua v5.4 one.c? And, module inclusion issue.
 
 
 
On Wed, May 13, 2020 at 1:05 PM Tony Papadimitriou <tonyp@acm.org> wrote:
BTW, has anything changed in how one statically includes modules in Lua 5.4?
I build Lua v5.3 to include sqlite3 (with lsqlite3) and lfs but with 5.4 although I get no compilation errors, and the size of the executable shows the modules are included, I get nil for either module.
 
The easiest way is adding the modules' luaopen_<name> functions to the table in 'linit.c', perhaps they're missing there?
 
Personally I prefer to assign the luaopen_... functions to the package.preload table (LUA_PRELOAD_TABLE in the registry). The modules won't pollute the global namespace and will only be activated if 'require' is called for them. I'm trying to keep the time required to create a new lua state low.
 
--


_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org