luac - Lua compiler


luac [ -c | -u ] [ -D name ] [ -d ] [ -l ] [ -O ] [ -o filename ] [ -p ] [ -q ] [ -v ] [ -V ] sourcefile ...


luac is the Lua compiler. It translates programs written in the Lua programming language into binary files that can be loaded and executed with lua_dofile in C or with dofile in Lua.

The main advantages of pre-compiling chunks are: faster loading, protecting source code from user changes, off-line syntax error detection. The binary files created by luac are portable to all known architectures.

luac produces a single output file containing the bytecodes for all source files given. By default, the output file is named luac.out, but you can change this with the -o option.

You can use "-" to indicate stdin as a source file.

luac can also load and list binary files with the -u option.

Binary files produced by differents runs of luac can be combined into one large file, using cat(1). The result is still a valid binary file, and can be loaded with a single call to lua_dofile or dofile.


-c compile (this is the default).

-u undump, i.e., load and list the given binary files. If no files are given, then luac undumps luac.out.

-D "name" predefine symbol name for conditional compilation.

-d turn debugging on. Individual chunks may still control the generation of debug information with $debug and $nodebug.

-l produce a listing of the compiled bytecode for Lua's virtual machine. This is the default when undumping.

-O optimize code. Debug information is removed, duplicate constants are coalesced.

-o "filename" output to filename, instead of the default luac.out. The output file cannot be a source file.

-p parse sources files but does not generate any output file. Used mainly for syntax checking.

-q quiet; produces no listing. This is the default when compiling.

-v print version information.

-V verbose; print the names of the source files as they are processed.


luac.out default output file


"Reference Manual of the Programming Language Lua"
"Lua: an extensible extension language", Software: Practice & Experience 26 #6 (1996) 635-652.


Error messages should be self explanatory.


Inherits any bugs from Lua, but Lua has no bugs...


L. H. de Figueiredo, R. Ierusalimschy and W. Celes (