A cross-platform ahead-of-time Lua compiler and runtime, using C++20 backend https://samyeyo.github.io/clx
  • C++ 40.4%
  • C 25.2%
  • HTML 18.7%
  • Lua 12.6%
  • Batchfile 0.9%
  • Other 2.1%
Find a file
Tine Samir bc2ee09e49
Add Weather CLI article to blog
Added a new article for Weather CLI to illustrate the new clx Lua C API compatibility layer introduced with clx 0.5.0
2026-11-04 15:30:19 +01:00
.github build: fix Windows static lib output dir and ship one archive per platform 2026-08-21 23:09:49 +02:00
benchmarks Replace pcall error-mix with direct branches, same checksums 2026-10-23 18:50:15 +02:00
deps build: Add Lua fetch scripts 2026-08-02 09:40:28 +02:00
doc chore: Bump version to 0.5.0 and update related documentation 2026-10-31 23:11:33 +01:00
examples examples: Build the sokol example module as C++20 2026-10-31 14:44:22 +01:00
include runtime: Fix MSVC build: __declspec(noinline) and rename the small parameter 2026-10-31 14:44:32 +01:00
src vm: Build the embedded Lua VM as C++20 2026-10-31 14:45:03 +01:00
tests tests: Build native test modules as C++20 2026-10-31 14:45:34 +01:00
www Add Weather CLI article to blog 2026-11-04 15:30:19 +01:00
.gitattributes Add .gitattributes to enforce LF line endings 2026-06-21 15:42:54 +02:00
.gitignore Stop gitignoring deviations.md; both it and article.md live in .git/info/exclude 2026-10-23 11:32:10 +02:00
build.bat build: Bootstrap the MSVC environment so a plain prompt can build clx 2026-10-31 14:43:30 +01:00
build.sh build: build.sh/build.bat now forward any CLX_* env vars generically to CMake. 2026-08-31 20:36:57 +02:00
CHANGELOG.md chore: Bump version to 0.5.0 and update related documentation 2026-10-31 23:11:33 +01:00
CMakeLists.txt chore: Bump version to 0.5.0 and update related documentation 2026-10-31 23:11:33 +01:00
CONTRIBUTING.md Correct CONTRIBUTING documentation 2026-10-18 20:14:14 +02:00
FAQ.md build: Update requirements to use C++17 instead of C++20 across all files 2026-10-24 09:08:49 +02:00
LICENSE doc: fixed typo in LICENSE 2026-08-02 16:52:00 +02:00
README.md docs: Updated benchmarks for Linux x64 2026-10-31 21:48:51 +01:00

CLX Logo

Cross-platform ahead-of-time Lua compiler

Lua 5.5 C++20 License: MIT ko-fi



clx is a cross-platform ahead-of-time Lua compiler and runtime that generates standalone native executables through modern C++ toolchains. clx is not trying to be the fastest Lua implementation in every workload.

Quick Start

git clone https://github.com/samyeyo/clx.git
cd clx
./build.sh install       # or build.bat install on Windows
clx examples/hello/hello.lua
./hello

Hello clx!

What makes clx useful

  • Just write Lua. clx targets Lua 5.5, so your code works like ordinary Lua.
  • Fast native speed — your scripts are compiled to native machine code.
  • Efficient memory management — a generational garbage collector tuned for short-lived data.
  • Standalone binaries — no interpreter or extra runtime to install alongside your program.
  • Small outputs — size-friendly builds can create very compact executables.
  • Cross-platform — works on Linux, macOS, and Windows.
  • Extensible — Compatible with the Lua 5.5 C API: just recompile your existing binary modules and clx links them into the final executable seamlessly — no code changes.

Examples built with clx

clx ships real, runnable examples that show native desktop application development using standard Lua code.

Pong

Pong

A complete game written in Lua and compiled into a standalone native executable.

Mandelbrot viewer

Mandelbrot

A Mandelbrot viewer written in Lua and compiled into a standalone native executable.

Project status

clx is currently in beta. It can already compile real Lua applications, and compatibility and performance work continues.

Requirements

  • Linux: g++ or clang++
  • macOS: clang++ (Xcode) or g++ via Homebrew
  • Windows: MSVC (cl), LLVM clang-cl, or g++ (MinGW)
  • CMake 3.15+ to build from source

The compiler that builds clx is the same one used to compile your Lua scripts, keeping everything consistent. If you need a different compiler, just rebuild clx with it.

Using clx

The easiest way to use clx is to compile a Lua file into a runnable program:

clx file.lua          # compiles file.lua and produces an executable
./file                # run it

A few common options when you need more control:

clx file.lua --size        # optimize for size (default)
clx file.lua --fast        # optimize for speed
clx file.lua --output app  # give the output a custom name
clx file.lua --dynamic     # allow loading Lua code at runtime
clx --help                 # see all options
  • load() / loadfile() / dofile() run on an embedded Lua engine and are only available when you compile with --dynamic. See Dynamic Lua.
  • To write native modules, clx supports both its own clx C++ API and the standard Lua 5.5 C API (lua.h, lauxlib.h, lualib.h) — existing C modules compile and run unchanged and are linked into the executable with --modules. See Modules and the Lua C API.

Benchmarks

clx compares well against the reference Lua 5.5 interpreter:

Script lua 5.5 LuaJIT clx --fast
fib.lua 0.299s (1.00x) 0.049s (6.10x) 0.006s (49.83x)
arraysum.lua 0.305s (1.00x) 0.086s (3.55x) 0.090s (3.39x)
spectralnorm.lua 0.328s (1.00x) 0.021s (15.62x) 0.019s (17.26x)
canada.lua 0.356s (1.00x) 0.148s (2.41x) 0.244s (1.46x)
warmup.lua 0.008s (1.00x) 0.006s (1.33x) 0.004s (2.00x)

Measured on an Intel® Core™ Ultra 5 125U CPU @ 4.30GHz · Linux · GCC 15.2.0 · Average of 10 runs · clx --fast built with AVX2 (CLX_ARCH=avx2)

Full benchmarks are available in clx benchmarks

Documentation

Detailed guides live in the doc/ directory:

Start at the Documentation Index.

License

clx is MIT Licensed — Copyright (c) 2026 Tine Samir