Skip to main content

Building from Source

QuickJS uses CMake as its primary build system, with a convenient Makefile wrapper for Unix-like systems.
Windows users need to run CMake commands manually. See the Windows build instructions below.

Prerequisites

1

Install build tools

2

Clone the repository

Standard Build

1

Build with Makefile (Linux/macOS)

The simplest way to build QuickJS:
This creates:
  • build/qjs - The QuickJS interpreter
  • build/qjsc - The QuickJS compiler
  • build/libquickjs.a - Static library
  • Additional test tools
2

Install system-wide

Default installation prefix is /usr/local. To customize:

Build Types

Debug Build

For development work with debug symbols and no optimizations:
Or manually:
Debug builds are essential for debugging with gdb or lldb. They include symbols and disable optimizations that can make debugging difficult.

Release Build

Optimized build for production (default):

Shared Library Build

Build QuickJS as a shared library:

CMake Build Options

QuickJS supports several CMake options for customization:

Example: Build with Options

Sanitizers (ASAN, MSAN, TSAN, UBSAN) are for testing only. Don’t use them in production builds as they significantly impact performance.

Platform-Specific Builds

Windows

1

Generate Visual Studio project

2

Build the project

3

Run the binaries

MinGW on Windows

Cross-Compilation

For ARM or other architectures, use a CMake toolchain file:

Amalgamated Build

The amalgamated build combines all QuickJS source files into a single quickjs-amalgam.c file. This is ideal for embedding in projects without CMake.
1

Build QuickJS first

2

Generate amalgamated source

This creates build/quickjs-amalgam.zip containing:
  • quickjs-amalgam.c
  • quickjs.h
  • quickjs-libc.h
3

Use in your project

To enable the std, os, and bjson modules in amalgamated builds, compile with -DQJS_BUILD_LIBC.

Testing

Run Test262 Suite

Test QuickJS against the official ECMAScript test suite:
This runs the test262 conformance tests.

Update Test Results

After implementing new features, update the test results:
This regenerates the error/pass report based on current test results.

Advanced Build Options

Parallel Builds

Speed up compilation by using multiple CPU cores:

Custom Installation Prefix

Static REPL Executable

Build a fully static qjs binary:

Build with mimalloc

Use the mimalloc allocator for better performance:

Cleaning Build Artifacts

Verifying the Build

After building, verify everything works:
1

Test the interpreter

2

Test the compiler

3

Check statistics

This displays QuickJS internal statistics.

Troubleshooting

Build Fails with Missing Dependencies

Make sure you have all required tools:

Linker Errors

Ensure you’re linking all required libraries:

Permission Errors During Install

Use sudo for system-wide installation:
Or install to a user directory:

Next Steps

Quick Start

Start using your QuickJS build

API Reference

Learn the QuickJS C API

Examples

Explore code examples

Contributing

Contribute to QuickJS development