emcc
TLDR
Compile C to WebAssembly
SYNOPSIS
emcc [options] files
DESCRIPTION
emcc (Emscripten Compiler Frontend) compiles C and C++ code to WebAssembly (Wasm) or JavaScript using LLVM and Emscripten. It enables running native code in web browsers and other Wasm runtimes.
Emscripten provides a compatibility layer for POSIX APIs, OpenGL (via WebGL), and SDL. It can compile entire codebases including games and applications to run in browsers.
PARAMETERS
-o file
Output file (.js, .wasm, .html).-O0 to -O3, -Os, -Oz
Optimization levels.-s SETTING=VALUE
Emscripten-specific settings.-I dir
Include directory.-L dir
Library directory.-l lib
Link library.-g
Generate debug information.--preload-file path
Preload file into virtual filesystem.--embed-file path
Embed file in output.-sMODULARIZE
Output as ES6 module.
CAVEATS
Not all C/C++ features work identically. File system access requires virtual filesystem. Threading needs SharedArrayBuffer. Performance differs from native. Large applications may have long compile times. Browser security restrictions apply.
HISTORY
Emscripten was created by Alon Zakai at Mozilla in 2011, initially targeting asm.js before WebAssembly existed. When WebAssembly launched in 2017, Emscripten became the primary compiler toolchain for bringing C/C++ to the web.


