Skip to main content
QuickJS-ng provides extensive build configuration options through both CMake and Meson build systems. This guide covers all available options and their usage.

Build Systems

QuickJS-ng supports two build systems:

CMake

Industry-standard build system with broad platform support

Meson

Modern, fast build system with excellent cross-compilation support

CMake Build Options

Library Options

BUILD_SHARED_LIBS

BUILD_SHARED_LIBS
boolean
default:"OFF"
Build QuickJS as a shared library instead of static library.
cmake -B build -DBUILD_SHARED_LIBS=ON

QJS_BUILD_LIBC

QJS_BUILD_LIBC
boolean
default:"OFF"
Build standard library modules as part of the library. When enabled, quickjs-libc.c is compiled into the main library.
cmake -B build -DQJS_BUILD_LIBC=ON

CLI Options

QJS_BUILD_CLI_STATIC

QJS_BUILD_CLI_STATIC
boolean
default:"OFF"
Build a static qjs executable with all dependencies linked statically.
cmake -B build -DQJS_BUILD_CLI_STATIC=ON

QJS_BUILD_CLI_WITH_MIMALLOC

QJS_BUILD_CLI_WITH_MIMALLOC
boolean
default:"OFF"
Build the qjs executable with mimalloc allocator (dynamically linked).
cmake -B build -DQJS_BUILD_CLI_WITH_MIMALLOC=ON

QJS_BUILD_CLI_WITH_STATIC_MIMALLOC

QJS_BUILD_CLI_WITH_STATIC_MIMALLOC
boolean
default:"OFF"
Build the qjs executable with mimalloc allocator (statically linked).
cmake -B build -DQJS_BUILD_CLI_WITH_STATIC_MIMALLOC=ON

Feature Options

QJS_DISABLE_PARSER

QJS_DISABLE_PARSER
boolean
default:"OFF"
Disable JavaScript source code parser. Useful for environments that only execute bytecode.
cmake -B build -DQJS_DISABLE_PARSER=ON
When QJS_DISABLE_PARSER is enabled, you can only execute pre-compiled bytecode. The qjsc compiler and qjs REPL will not be built.

Examples and Tests

QJS_BUILD_EXAMPLES

QJS_BUILD_EXAMPLES
boolean
default:"OFF"
Build example programs including:
  • hello - Simple hello world
  • hello_module - Module example
  • test_fib - Fibonacci test
  • fib.so / point.so - Native module examples
cmake -B build -DQJS_BUILD_EXAMPLES=ON

Compiler Options

QJS_BUILD_WERROR

QJS_BUILD_WERROR
boolean
default:"OFF"
Build with -Werror flag, treating all warnings as errors.
cmake -B build -DQJS_BUILD_WERROR=ON

Sanitizer Options

QuickJS-ng supports multiple sanitizers for development and debugging:

QJS_ENABLE_ASAN

QJS_ENABLE_ASAN
boolean
default:"OFF"
Enable AddressSanitizer (ASan) for detecting memory errors.
cmake -B build -DQJS_ENABLE_ASAN=ON

QJS_ENABLE_MSAN

QJS_ENABLE_MSAN
boolean
default:"OFF"
Enable MemorySanitizer (MSan) for detecting uninitialized memory reads.
cmake -B build -DQJS_ENABLE_MSAN=ON
MSan only works with Clang at the time of writing.

QJS_ENABLE_TSAN

QJS_ENABLE_TSAN
boolean
default:"OFF"
Enable ThreadSanitizer (TSan) for detecting data races.
cmake -B build -DQJS_ENABLE_TSAN=ON
TSan is currently incompatible with other sanitizers.

QJS_ENABLE_UBSAN

QJS_ENABLE_UBSAN
boolean
default:"OFF"
Enable UndefinedBehaviorSanitizer (UBSan) for detecting undefined behavior.
cmake -B build -DQJS_ENABLE_UBSAN=ON

WASI Options

QJS_WASI_REACTOR

QJS_WASI_REACTOR
boolean
default:"OFF"
Build WASI reactor module that exports library functions without _start entry point.
cmake -B build -DCMAKE_SYSTEM_NAME=WASI -DQJS_WASI_REACTOR=ON
Only available when CMAKE_SYSTEM_NAME is set to WASI.

Meson Build Options

Core Options

libc

libc
boolean
default:"false"
Build qjs standard library modules as part of the library.
meson setup build -Dlibc=true

parser

parser
boolean
default:"true"
Enable JavaScript source code parser.
meson setup build -Dparser=false

CLI Options

cli_mimalloc

cli_mimalloc
feature
default:"disabled"
Build qjs CLI with mimalloc allocator.Options: enabled, disabled, auto
meson setup build -Dcli_mimalloc=enabled

Development Options

tests

tests
feature
default:"auto"
Build tests including Test262 runner and benchmarks.
meson setup build -Dtests=enabled

examples

examples
feature
default:"auto"
Build example programs.
meson setup build -Dexamples=enabled

docdir

docdir
string
default:""
Documentation installation directory.
meson setup build -Ddocdir=/usr/share/doc/quickjs-ng

Common Build Configurations

Development Build

cmake -B build \
  -DCMAKE_BUILD_TYPE=Debug \
  -DQJS_BUILD_EXAMPLES=ON \
  -DQJS_ENABLE_ASAN=ON
cmake --build build

Production Build

cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_SHARED_LIBS=ON \
  -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build build
cmake --install build

Static Library Build

cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_SHARED_LIBS=OFF \
  -DQJS_BUILD_CLI_STATIC=ON
cmake --build build

Bytecode-Only Build

cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DQJS_DISABLE_PARSER=ON
cmake --build build

Environment Variables

All CMake options can also be set via environment variables:
export BUILD_SHARED_LIBS=ON
export QJS_BUILD_EXAMPLES=ON
cmake -B build

Build Type Options

CMake Build Types

  • Debug - No optimization, full debug symbols
  • Release - Full optimization, no debug symbols
  • RelWithDebInfo - Optimization with debug symbols
  • MinSizeRel - Optimize for size
cmake -B build -DCMAKE_BUILD_TYPE=Release

Meson Build Types

  • debug - No optimization, full debug info
  • release - Full optimization
  • debugoptimized - Optimization with debug info
  • minsize - Optimize for size
meson setup build --buildtype=release

Installation Prefix

cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --install build

Using Makefile Wrapper

The included Makefile provides convenient shortcuts for common operations:
# Build with default settings (Release)
make

# Debug build
make debug

# Install to /usr/local (or INSTALL_PREFIX)
make install

# Clean build directory
make clean

# Remove build directory completely
make distclean

# Build with custom settings
make BUILD_TYPE=Debug INSTALL_PREFIX=/opt/quickjs

Parallel Builds

Both build systems support parallel builds:
cmake --build build -j $(nproc)

Build docs developers (and LLMs) love