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
Standard Build
Build with Makefile (Linux/macOS)
The simplest way to build QuickJS:This creates:
build/qjs- The QuickJS interpreterbuild/qjsc- The QuickJS compilerbuild/libquickjs.a- Static library- Additional test tools
Build Types
Debug Build
For development work with debug symbols and no optimizations: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:| Option | Description | Default |
|---|---|---|
BUILD_SHARED_LIBS | Build shared library instead of static | OFF |
QJS_BUILD_WERROR | Build with -Werror (treat warnings as errors) | OFF |
QJS_BUILD_EXAMPLES | Build example programs | OFF |
QJS_BUILD_CLI_STATIC | Build static qjs executable | OFF |
QJS_DISABLE_PARSER | Disable JavaScript parser | OFF |
QJS_ENABLE_ASAN | Enable AddressSanitizer | OFF |
QJS_ENABLE_MSAN | Enable MemorySanitizer | OFF |
QJS_ENABLE_TSAN | Enable ThreadSanitizer | OFF |
QJS_ENABLE_UBSAN | Enable UndefinedBehaviorSanitizer | OFF |
Example: Build with Options
Platform-Specific Builds
Windows
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 singlequickjs-amalgam.c file. This is ideal for embedding in projects without CMake.
Generate amalgamated source
build/quickjs-amalgam.zip containing:quickjs-amalgam.cquickjs.hquickjs-libc.h
Testing
Run Test262 Suite
Test QuickJS against the official ECMAScript test suite:Update Test Results
After implementing new features, update the test results:Advanced Build Options
Parallel Builds
Speed up compilation by using multiple CPU cores:Custom Installation Prefix
Static REPL Executable
Build a fully staticqjs binary:
Build with mimalloc
Use the mimalloc allocator for better performance:Cleaning Build Artifacts
Verifying the Build
After building, verify everything works: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
Usesudo for system-wide installation:
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