[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Statically linking luasocket
- From: Brian Murphy <brian@...>
- Date: Fri, 21 Oct 2005 00:25:21 +0200
Issac Trotts wrote:
Hi all,
The installation instructions for luasocket describe how to install it
as a dynamic library. For my application, it would be preferable to
just compile luasocket in statically, but this only half working. I
had to change a couple of headers:
Try not changing anything and putting this in your startup code:
/* package.preload["lsocket"] = luaopen_lsocket */
lua_pushstring(L, "lsocket");
lua_pushcfunction(L, luaopen_lsocket);
lua_settable(L, -3);
/* package.preload["lmime"] = luaopen_lmime */
lua_pushstring(L, "lmime");
lua_pushcfunction(L, luaopen_lmime);
lua_settable(L, -3);
this gets the C initialization functions called at the right stage of
the module
loading process(after the lua code). If you the "C" functions directly
then the later require"socket" fails because the module globals are
already defined and this
is what the package system uses to signal that the module is already loaded.
/Brian