4 ms·
Using this library and others, there's a neat trick to make Lua GUI programs that fit in a single executable file without dependencies. Of course, the tradition
by pierrec 10y ago
Using this library and others, there's a neat trick to make Lua GUI programs that fit in a single executable file without dependencies. Of course, the traditional "brute force" way of doing this is to make a self-extracting archive. But the classier way is to use srlua:
http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/#srlua http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/#srlua
Basically, it's a slightly modified Lua interpreter, which you literally concatenate with your script. When run, the interpreter tries to run the script that's appended. Although the srlua documentation was pretty vague on the subject, I've successfully linked it statically with this IUP library, so the appended script can load it and display a nice GUI. Maybe not always the optimal way of distributing programs, but I thought it was cool (you could even make an executable that allows you to graphically edit its own Lua source, though you might have to work around the fact that a running file isn't writable on some platforms).
- ers35 10y agoYou may be interested in a tool I wrote that builds standalone executables: https://github.com/ers35/luastatic https://github.com/ers35/luastatic For the following program: iup.Message('test', 'hello world') Build the program to a standalone executable: luastatic example.lua /usr/lib/x86_64-linux-gnu/liblua5.2.a -I/usr/include/lua5.2 libiup.a libiuplua52.a libiupcontrols.a `pkg-config --cflags --libs gtk+-3.0` -lX11