Search code examples
lualuasocket

How to build luasockets 3.0 for lua 5.3


I need to build lua-redis. Lua-dedis depends on luasockets. Luasockets 2.0 fail to build : my question on sockets 2.0 and lua 5.3 I was proposed to use luasockets 3.0. I make them, but they are installed into lua 5.1 and lua 5.3 still doesn't see this library:

root@debian:/home/debian/luasocket-master# make install
make -C src install
make[1]: Entering directory `/home/debian/luasocket-master/src'
install -d /usr/local/share/lua/5.1
install -m644 ltn12.lua socket.lua mime.lua /usr/local/share/lua/5.1
install -d /usr/local/share/lua/5.1/socket
install -m644 http.lua url.lua tp.lua ftp.lua headers.lua smtp.lua /usr/local/share/lua/5.1/socket
install -d /usr/local/lib/lua/5.1/socket
install socket-3.0-rc1.so /usr/local/lib/lua/5.1/socket/core.so
install -d /usr/local/lib/lua/5.1/mime
install mime-1.0.3.so /usr/local/lib/lua/5.1/mime/core.so
make[1]: Leaving directory `/home/debian/luasocket-master/src'
root@debian:/home/debian/luasocket-master# lua
Lua 5.3.2  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require('socket')
stdin:1: 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'

How can I change target lua version?

This is not duplicate of my question regarding sockets 2.0, because it is different codebase and different problem. Sockets 2.0 fail to compile and sockets 3.0 fail to install.


Solution

  • A look at the Makefile reveals the following:

    install-both:
        $(MAKE) clean
        @cd src; $(MAKE) $(PLAT) LUAV=5.1
        @cd src; $(MAKE) install LUAV=5.1
        $(MAKE) clean
        @cd src; $(MAKE) $(PLAT) LUAV=5.2
        @cd src; $(MAKE) install LUAV=5.2
        $(MAKE) clean
        @cd src; $(MAKE) $(PLAT) LUAV=5.3
        @cd src; $(MAKE) install LUAV=5.3
    

    The src/Makefile uses the variable LUAV to select the include files / install paths / ….

    Which means that you can also call this directly for the version you're interested in (and combine all make invocations into one):

    make clean all install LUAV=5.3