LHF's Lua script-to-binary executable utility

Skip to first unread message

Alexander Walz

unread,
Jun 9, 2025, 4:06:44 PMJun 9
to lu...@googlegroups.com

Hello,

 

Luiz Henrique de Figueiredo once published a tool - srglue, srlua - to convert a Lua script to an executable binary.

 

This is a miraculous few-lines piece of code that I adapted to a Lua fork, Agena.

 

The adapations to LHF's code are:

- Due to unknown reasons, command-line options passed to the generated executable often got corrupted, at least on 
  Windows (argv corruption). This has been fixed by passing them in a wholy different way internally, on all platforms.

- On the command-line, the Windows executables generated can be run without giving the `.exe' suffix explicitly.

- On Windows, both srglue and sr(lua) can be called without the full absolute path if the respective executables 
  are somewhere in your path.

- During generation of the executable, some status information will be printed to stderr.

 

The fix works successfully on Solaris, Linux, Mac OS X and Windows.

 

You can download the modified source code from:

 

   https://sourceforge.net/projects/agena/files/Packages/sragena-102.zip/download
   
If you are interested, I may adapt the sources to work with Lua 5.1.

 

Alex



blog...@gmail.com

unread,
Jun 9, 2025, 4:24:27 PMJun 9
to lua-l
>Lua script-to-binary executable utility

Good, Im have same util for creater single executable binary but use other way, my util take lua source host and lua script, first build host and use host luac for create bytecode, next generate C header with bytecode and generate C source, last just build with musl independed of any system binary out file.  Works from lua5.1 to lua5.4 just give source dir for utilite and press ENTER :)

I haven't posted this yet, but maybe I should and it might be useful to someone other than me. Thanks for sharing.

>During generation of the executable, some status information will be printed to stderr.

Some people really don't like this, because they often call utilities inside their strips and their scripts perceive data on stderr as an error or warning. I haven't tried your utility, but it would be useful to have a key that suppresses the output of information messages to stderr, for cases when the user would expect only errors to be displayed there. I myself output data to stderr in my utilities when stdin is busy, but sometimes this causes incidents, so whenever possible I try to add a startup key indicating that only errors or serious warnings can be output there, so that the automation that expects such behavior works correctly. Like --silent or --sidable-info or other

::)
понедельник, 9 июня 2025 г. в 23:06:44 UTC+3, Alexander Walz:

Alexander Walz

unread,
Jun 9, 2025, 4:37:53 PMJun 9
to lu...@googlegroups.com

I find LHF's tool magic. It works beautifully fine for me. And yes, I spent my whole weekend on getting it done on Windows.

 

 

 

 

-----Original-Nachricht-----

Betreff: Re: LHF's Lua script-to-binary executable utility

Datum: 2025-06-09T22:24:45+0200

Von: "blog...@gmail.com" <blog...@gmail.com>

An: "lua-l" <lu...@googlegroups.com>

 

 

 

--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/9f7252fa-8e1e-47cc-9f8b-6919eb16da24n%40googlegroups.com.

 



Michael Bonnet

unread,
Jun 10, 2025, 12:57:33 PMJun 10
to lua-l
This is a little far from the specific topic, but I've used `xxd -i` to turn Lua files into byte arrays that I then use in a C program that just creates a Lua state and executes the byte array as a Lua string.
Reply all
Reply to author
Forward
0 new messages