is there a way to create a standalone executable from a simple lua scripts? by simple i mean: i'm just using what lua 5.1 provides.
if so, is there some sort of "cross-compiler" available? i would like create executables for a linux system on my mac osx system.
thanks in advance!
You can make Lua scripts executable with chmod +x
and adding #!/usr/bin/env lua
. But you'll need to have a Lua interpreter installed. For a different approach, see my srlua.
murgaLua packs a single executable compiler, and squish is also reaaaalllly nice to compress lua scripts and even other files and directory trees in 1 simple to distribute file (although you still need a runtime to execute that file).
I don't know of any "out-of-the-box" ready for this.
A quite straight forward approach would be to modify the lua interpreter that is shipped with lua to include your custom scripts in the binary (and possibly disable the interactive options of it).
This way you can kick off your script with that executable.
There is a lua2bin (if I remember its name correctly) to convert a lua script to a c-file you may include with your application.
try using Lua's bin2c which will give you C source code of your lua script. If you are using external lua libraries it may be a bit more difficult to pull off, but squish can help with that. Or you can just luaL_loadstring everything
LuaJIT 2.0.4 has been released 2015-05-14
(I'm using it on a debian based linux (Crunchbang)
http://luajit.org
$ luajit -v
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
$ luajit -e 'print(_VERSION)'
Lua 5.1
(stick this at the top of your script)
#!/usr/bin/env luajit