lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, 18 Mar 2009 18:35:27 +0100
Ben Aurel <> wrote:

> One question not fully related to tekui: do you know a solution to
> deploy a program in a single self executable .exe? Scripts and
> interpreter in one exe?

If I'm not mistaken, you need to find a way to convert your script (or
bytecode) to a binary object, which can then be linked to your
application. How this is best achieved is specific for your compiler or
toolchain. Next, you use Lua's C API to create an interpreter state,
and then lua_load() with an appropriate reader callback to load your
initial script from memory. Finally, you can run it using lua_pcall(). 

As for how to package accompanying Lua modules into the same binary, I
would have to investigate that more thoroughly, but I think this has
been discussed here before. One approach I once pursued was to replace
Lua's iolib and loadlib to implement a virtual filesystem. I was then
able to write handlers for loading from memory or from a zip file, e.g.

f ="memfile:0x12345678,0x00010000")
io.mount("archive", "zipfs", "")
f ="archive:foo/bar")


I guess I will soon have to reanimate this approach, because we would
like to have a C library encapsulating Lua, tekUI's C modules and
tekUI's class library, forming a single binary blob.

- Timm

Timm S. Mueller <>
Schulze & Mueller GbR, Erbacher Straße 26, 64342 Seeheim-Jugenheim,
Gesellschafter: Franciska Schulze, Timm S. Mueller,
Tel. +49 6257 648853-0,