How to build luasockets for lua 5.3

2019-09-09 08:16发布

问题:

I try to use library redis-lua, which I've downloaded here:

https://github.com/nrk/redis-lua

It fails this way:

Lua 5.3.2  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require 'redis'
table: 0x84caea0
> r = require 'redis'
> r.connect('127.0.0.1',1234)
./redis.lua:791: module 'socket' not found:
    no field package.preload['socket']
    no file '/usr/local/share/lua/5.3/socket.lua'
    no file '/usr/local/share/lua/5.3/socket/init.lua'
    no file '/usr/local/lib/lua/5.3/socket.lua'
    no file '/usr/local/lib/lua/5.3/socket/init.lua'
    no file './socket.lua'
    no file './socket/init.lua'
    no file '/usr/local/lib/lua/5.3/socket.so'
    no file '/usr/local/lib/lua/5.3/loadall.so'
    no file './socket.so'

redis-lua documentation proposes to use http://w3.impa.br/~diego/software/luasocket/

this leads me to the following page: http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz

Building these sources gives me following error:

debian@debian:~/luasocket-2.0.2$ make install
cd src; make all
make[1]: Entering directory `/home/debian/luasocket-2.0.2/src'
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o luasocket.o luasocket.c
In file included from luasocket.c:31:
auxiliar.h:38: error: expected declaration specifiers or ‘...’ before ‘luaL_reg’
luasocket.c:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mod’
luasocket.c:60: warning: ISO C does not allow extra ‘;’ outside of a function
luasocket.c:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘func’
luasocket.c:66: warning: ISO C does not allow extra ‘;’ outside of a function

Please propose how to add socket support to lua 5.3.

标签: lua