LIGHT THEME

Installation

How to install Lua2Exe to different systems

Windows

Download release from here, unpack somewhere so exe is in your %PATH% environment variable, and edit the Config.lua to suit your environment. The entries's purpose is written in file, as well as in section below.

Other systems

You will need to compile it from the source, the Make.ps1 is included, so just run it if you have powershell, gcc and Lua. Or edit it to suit your shell and environment. After compilation, edit the Config.lua to suit your environment. At last, you need to either move it somewhere Lua can include config from, or pass "-conf path" for each compilation.

Why more work for other systems: On non Windows systems, Lua cannot include files in the exe's directory, in which config is; and i don't have a compiler (or don't know how) to compile L2E for other systems.


Config

What each entry does

LibDir — Folder where libs sit. By default folder with compiler itself.

IncludeDir — Folder where Lua includes sit. By default folder with compiler itself/Include.

Compiler — C compiler in your system to be invoked on compilation. Supported values are "gcc", "clang", "tcc". I don't like this external compiler dependency for many reasons, and in the next update it will probably be replaced by embedded compiler


Options

Detailed explanation what every option does

Note that you can use options with both '-' for Linux style, or with '/' for Windows style

-o File — Set output file name

-c Compiler — Set C compiler. Overwrites value from config.

-conf Path — Set L2E config file. File shall be accessible for require (without .lua extension). This is a crutch for portability, as i don't know other good way to do this.

-s — Strip debug information. Tells C compiler to strip symbols from exe, and tells Lua to strip debug from loaded code.

-dll — Make exe dynamically linked. The libLuadll.dll is shipped with a compiler, and i don't know if Linux's C compiler can link to DLL, maybe you will need to rename it to shared object.

-M — Only merge files into one, do not compile. Analog of -E for C i think.

-C — Only compile files to C, do not compile to exe. C file contains definition of libraries and bytecode.

-v — Be verbose; Currently it only prints command for C compiler

-np — Remove parsing related C code. By C code i mean lexing, parsing and code generation libraries. This reduces output exe size, but takes away ability to load any text chunks. Program will notify you and throw an error on attempt. Probably will not take effect if exe is dynamically linked, as whole Lua is in dll.

-a Options — Additional options to pass to C compiler. Options are passed before any file. If multiple "-a" passed, the last will be used.

-[h | ?] — Display help.


How to

How to use features of the L2E

General template for any compilation is "l2e [options] [modules...] main_file"

Lua dependencies

Lua doesn't have "main" function like C does, and thus compiler doesn't know which one is it. Because of this, order of input files matters: main file is last Lua file. L2E uses Lua's built-in searchers to find modules, this means you need to just copy paste names from require(); that is My.lua turns into My

C dependencies

All you need to add C dependency to standalone exe is object file with your dependency. Pass object file (with .o extension) to the compiler and that's all. The only mandatory function is luaopen_<filename without extension>, the same name that Lua's loader uses to load dlls. In Lua you can use it as global, or with require(), as if using the dll. L2E treats each object file as separate library.