[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Linking LuaSocket statically
- From: Martin Velek <martin.velek@...>
- Date: Fri, 30 Jul 2010 09:25:11 +0200
Hi Andrew,
it works like a charm :).
Thank you very much.
Regards,
Martin
On 29 July 2010 23:47, Andrew Cannon <ajc@gmx.net> wrote:
>
> ...a small addendum to my last post:
>
> In addition to the changes below, the lua scripts for socket and mime have to be
> modified as follows:
>
> In socket.lua change the line:
>
> local socket = require("socket.core")
> to:
> local socket = require("socket")
>
> Similarly in mime.lua "mime.core" -> "mime"
>
> This is because in the statically linked case the C module is loaded first (by
> linit.c), but the module it creates is called "socket" and not "socket.core".
>
> Sorry for any confusion!
> Andrew
>
> ps: now tested and does work with lua 5.1.4 too.
>
>
>
> Andrew Cannon wrote:
>> Hi,
>>
>> a while ago I made a statically-linked luasocket for a project running uclinux
>> on Blackfin with no shared libraries. This was for lua 5.1.3 though so it may be
>> that the exact details of the module handling have changed a bit...?
>>
>> In linit.c I added entries to the end of the module table lualibs[] (with the
>> appropriate protos of course):
>>
>> ->>>
>> int luaopen_mime_core (lua_State *L);
>> int luaopen_socket_core (lua_State *L);
>> -<<<
>> ...
>> static const luaL_Reg lualibs[] = {
>> ...
>> ->>>
>> {"mime", luaopen_mime_core},
>> {"socket", luaopen_socket_core},
>> -<<<
>> {NULL, NULL}
>> };
>>
>> This loads the core C modules socket.core and mime.core. To load the lua bits I
>> put the following lines in the initialisation file (specified in $LUA_INIT as
>> "@full_path_to_file"):
>>
>> ->>>
>> loadfile("/usr/share/lua/5.1/socket.lua")()
>> loadfile("/usr/share/lua/5.1/mime.lua")()
>> -<<<
>>
>> This has to be done explicitly because if you just call (require"socket") the
>> loader will think the module is already loaded and do nothing.
>>
>> Hope that helps anyone trying to do the same
>> Andrew
>>
>