The Emscripten toolchain is distributed as a standalone Emscripten SDK. The SDK provides all the required tools, such as Clang, Python and Node.js along with an update mechanism that enables migrating to newer Emscripten versions as they are released.
You can also set up Emscripten from source, without the pre-built SDK, see "Installing from Source" below.
To get started with Emscripten development, see the Emscripten website documentation.
That explains how to use the emsdk to get the latest binary builds (without compiling from source). Basically, that amounts to
git pull
./emsdk install latest
./emsdk activate latest
The Emscripten SDK is effectively a small package manager for tools that are used in conjunction with Emscripten. The following glossary highlights the important concepts to help understanding the internals of the SDK:
- Tool: The basic unit of software bundled in the SDK. A Tool has a name and a version. For example, 'clang-3.2-32bit' is a Tool that contains the 32-bit version of the Clang v3.2 compiler.
- SDK: A set of tools. For example, 'sdk-1.5.6-32bit' is an SDK consisting
of the tools
clang-3.2-32bit,node-0.10.17-32bit,python-2.7.5.1-32bitandemscripten-1.5.6. - Active Tool/SDK: Emscripten SDK stores compiler configuration in a file
called
.emscriptenwithin the emsdk directory. This file points to paths for Emscripten, Python, Clang and so on. If the configuration file points to a Tool in a specific directory, then that tool is denoted as being active. This mechanism allows switching between different installed tools and SDKs. - emsdk: This is the name of the manager script that Emscripten SDK is
accessed through. Most operations are of the form
emsdk <command>.
Using the emsdk pre-compiled packages requires only the minimal set of dependencies lists below. When building from source a wider set of tools include git, cmake, and a host compiler are required. See: https://emscripten.org/docs/building_from_source/toolchain_what_is_needed.html.
- macOS 11.0 or newer.
java: For running closure compiler (optional). After installing emscripten via emsdk, typing 'emcc --help' should pop up a OS X dialog "Java is not installed. To open java, you need a Java SE 6 runtime. Would you like to install one now?" that will automatically download a Java runtime to the system.
python: Version 3.8 or above.java: For running closure compiler (optional)
The emsdk pre-compiled binaries are built against debian/stretch (for x86_64)
and debian/bullseye (for arm64) sysroots and therefore depend on system
libraries compatible with the version of glibc (and other libraries) present
in those releases. If your linux distribution is very old you may not be able to
use the pre-compiled binaries packages. Note that libc++ is statically linked
so there should be no issues with older versions of libstdc++ or libc++.
java: For running closure compiler (optional)
To remove the Emscripten SDK, simply delete the emsdk directory.
The following tasks are common with the Emscripten SDK:
Run emsdk help or just emsdk to get information about all available commands.