Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Lua to executable

hi I have a Lua program (written in Lua 5.1). I'm on Windows 7, trying to convert it to an executable. No luck so far. I've read other posts here that suggested using srlua to do this so I've downloaded it but I'm on a loss as to what to do next. I installed cygwin as I understand it's necessary but I don't know how to use srlua to convert a lua file into an executable. Any help will be appreciated.

like image 612
maxam Avatar asked Aug 20 '13 16:08

maxam


1 Answers

srlua is distributed as source only, so you have to compile it first (see this answer for suggestions on getting a free C compiler).

BTW, Cygwin is not necessary at all. The aforementioned link will lead you to instructions to install TDM-GCC, a Windows port of GCC compiler that will create executable files which only depend on Windows default system libraries.

Once you have a C compiler in place and you have compiled srlua, you will have two executable files glue.exe and srlua.exe. This latter is only a stub, used by srlua.exe to generate the final executable by joining it with your Lua script.

Assuming your script is myscript.lua and you want to create an executable named myexe.exe you must invoke glue.exe from the command line as follows:

 glue.exe srlua.exe myscript.lua myexe.exe

I assumed that all the relevant files are placed in the same directory and you changed to that directory from the command line.

Addendum: I just double checked the official download page for srlua and I saw there is also a package with already compiled binaries for Windows. So you could skip all the compilation from source part and simply download and unpack this.

The binaries are in the Release subdirectory inside the archive. Note that these are for Lua 5.1 only, so if your script uses features of Lua 5.2 you must follow my initial advice and compile from source.

like image 146
Lorenzo Donati -- Codidact.com Avatar answered Oct 06 '22 21:10

Lorenzo Donati -- Codidact.com