talira

Emscripten

A complete compiler toolchain to WebAssembly, using LLVM

open sourceMIT OR NCSAfree

Emscripten compiles C and C++, or any language that uses LLVM, to WebAssembly that runs in browsers, Node.js or other Wasm runtimes. Its compiler frontend, emcc, is a drop-in replacement for gcc or clang: it uses Clang and LLVM to compile and emits JavaScript that gives the compiled code its APIs, converting OpenGL to WebGL and supporting SDL, pthreads, POSIX, the C and C++ standard libraries and exceptions, plus WebGPU and other Web APIs. It optimizes output with Binaryen and Closure Compiler for small, near-native-speed code. Projects from games to Qt, Unreal Engine 4 and Unity have been ported with it. The Emscripten SDK (emsdk) installs the whole toolchain on Linux, macOS or Windows.

Problems it solves

  • compile my C++ library to WebAssembly so it runs in the browser
  • port a C or C++ game to the web
  • run existing native code in Node.js without rewriting it in JavaScript
  • call C++ functions from JavaScript in a web app

Features

  • compiles C, C++ and other LLVM languages to WebAssembly
  • emcc, a drop-in replacement for gcc or clang
  • runs output in browsers, Node.js and other Wasm runtimes
  • OpenGL to WebGL, plus WebGPU and EGL
  • SDL, pthreads and POSIX APIs
  • C and C++ standard libraries and C++ exceptions
  • Embind and WebIDL Binder to connect C++ and JavaScript
  • virtual file systems
  • SIMD and Wasm Workers
  • Binaryen and Closure Compiler optimization
View 1 more
  • emsdk installer for Linux, macOS and Windows