lua-users home
lua-l archive

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


robert@infotility.com wrote:
> [...]
> robertdodier@boulder ~]$ export
> LUA_CPATH='/usr/local/lib/lua/5.1/socket/core.so'
> robertdodier@boulder ~]$ lua -l socket
> ua: error loading module 'socket' from file
> '/usr/local/lib/lua/5.1/socket/core.so':
>        /usr/local/lib/lua/5.1/socket/core.so: undefined symbol:
> luaopen_socket 
> 
> It seems odd that nm /usr/local/lib/lua/5.1/socket/core.so
> reports that luaopen_socket_core is defined (i.e. marked by T) in
> core.so; maybe that is the function that lua is looking for. 
> I tried other assignments (unsuccessful) to LUA_CPATH and LUA_PATH.
> 
> The only thing that works is:
> 
> cd /tmp/luasocket-2.0.1/src # i.e. cd to the build directory export
> LUA_CPATH='./?.so' 
> lua -l socket
> # now I get the lua interactive prompt
> 
> Maybe someone can explain
> (1) what is supposed to appear in /usr/local/lib/lua/5.1/socket
> (2) what is the appropriate setting for LUA_CPATH and/or LUA_PATH.

Just to clarify things, socket.lua contains a Lua module, and
socket/core.so contains *ANOTHER* module. Both work together, but what
is documented on LuaSocket website is socket.lua, not socket/core.so.

Now, as you use -lsocket switch, I assume you want to load the normal
LuaSocket. In that case you have to configure LUA_PATH to point to that
socket.lua, and also, as socket.lua will require socket/core.so, you
must make LUA_CPATH point to socket/core.so.

Assuming that you have these files there:
/usr/local/share/lua/5.1/socket.lua
/usr/local/lib/lua/5.1/socket/core.so

Your LUA_PATH and LUA_CPATH should look something like :
export LUA_PATH='/usr/local/share/lua/5.1/?.lua;;'
export LUA_CPATH='/usr/local/lib/lua/5.1/?.so;;'

And if you really want to load socket.core directly as you stated in
some previous email, you must use the -lsocket.core command line switch
instead of -lsocket.