fire command compiles and runs Fern applications. It can build single files for quick testing or entire projects with full configuration.
Usage
Options
Target platform:
linux, web, or macosShow help for the fire command
Arguments
Optional C++ source file to compile and run. If omitted, builds the current project.
Examples
Run Current Project
Run for Web Platform
Run Single File
Run Single File for Web
Platforms
Linux (Native)
Builds and runs a native Linux application:- Uses
g++compiler - Links against system X11 libraries
- Creates executable in
build/directory - Runs immediately after successful build
Web (WebAssembly)
Builds for web using Emscripten:- Uses
emcccompiler - Compiles to WebAssembly (.wasm)
- Uses precompiled Fern web library for faster builds
- Starts local HTTP server on port 3000 (or configured port)
- Opens browser automatically
- Generates
main.html,main.js, andmain.wasm
macOS (Experimental)
Builds for macOS using native frameworks:- Uses
clang++compiler - Links against Cocoa framework
- Uses Homebrew libraries for fontconfig/freetype
- Creates native macOS executable
Project vs Single File
Project Mode
When run without a file argument:- Searches for
fern.yamlin current directory and parents - Builds
lib/main.cppfrom project root - Uses project configuration settings
- Outputs to platform-specific directories (
build/,web/build/,linux/build/)
Single File Mode
When run with a file argument:- Compiles the specified file
- Creates temporary executable in
build/directory - Uses minimal configuration
- Ideal for quick testing and examples
Web Build Cache
Fire uses an intelligent caching system for web builds:- Precompiled Library - Fern source is compiled once to
~/.fern/cache/web/libfern_web.a - Incremental Builds - Only your code is recompiled on subsequent builds
- Cache Invalidation - Automatically rebuilds if Fern source changes
- Manual Control - Use
fern web-cacheto manage the cache
Build Output
Linux
Web
Configuration
Web server settings fromfern.yaml:
Common Workflows
Development Loop
Testing Examples
Error Handling
Not in a Fern project directory
Not in a Fern project directory
fern sprout.No main.cpp found
No main.cpp found
lib/main.cpp with your application code.Emscripten not found
Emscripten not found
fern bloom --troubleshoot).Compilation failed
Compilation failed
Fire displays compiler errors directly. Common issues:
- Missing
#includestatements - Syntax errors in C++ code
- Missing Fern headers (run
fern bloomto check installation)
Port already in use
Port already in use
Web Server Features
When running with-p web:
- Auto-reload - Refresh browser to see changes after recompiling
- Graceful shutdown - Press Ctrl+C to stop server cleanly
- Port selection - Automatically finds available port if default is in use
- Browser launch - Opens browser automatically to your app
- Custom template - Uses
web/template.htmlif present
Performance Tips
Web Builds
- First build is slower (~30s) as it compiles the Fern library
- Subsequent builds are fast (~5s) using cached library
- Clear cache with
fern web-cache clearif you update Fern source - Check cache with
fern web-cache statusto verify it’s current
Native Builds
- Debug builds (default) are faster to compile but slower to run
- Production builds use
fern prepare linuxfor optimized binaries - Incremental builds are automatic when supported
Advanced Usage
Custom Port
Custom Web Template
Createweb/template.html to customize the HTML wrapper:
{{{ SCRIPT }}} placeholder is replaced with the generated JavaScript.
Related Commands
fern prepare- Build optimized production binariesfern web-cache- Manage web build cachefern bloom- Check dependencies before buildingfern sprout- Create a new project to run