Emscripten下载和安装

备注

如果您不喜欢使用emsdk下载二进制文件,也可以 build Emscripten from source

小技巧

if you’d like to install emscripten using the unofficial packages instead of the officially supported emsdk, see the bottom of the page.

Verifying the installation

The easiest way to verify the installation is to compile some code using Emscripten.

You can jump ahead to the Emscripten教程, but if you have any problems building you should run through the basic tests and troubleshooting instructions in 验证Emscripten开发环境.

Updating the SDK

小技巧

You only need to install the SDK once! After that you can update to the latest SDK at any time using Emscripten SDK (emsdk).

Type the following in a command prompt

# Fetch the latest registry of available tools.
./emsdk update

# Download and install the latest SDK tools.
./emsdk install latest

# Set up the compiler configuration to point to the "latest" SDK.
./emsdk activate latest

# Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

The package manager can do many other maintenance tasks ranging from fetching specific old versions of the SDK through to using the versions of the tools on GitHub (or even your own fork). Check out all the possibilities in the “How to” guides.

Uninstalling the Emscripten SDK

If you want to remove the whole SDK, just delete the directory containing the SDK.

It is also possible to remove specific tools in the SDK using emsdk.

Using the Docker image

The entire Emscripten SDK is also available in the form of a docker image. For example:

docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) \
  emscripten/emsdk emcc helloworld.cpp -o helloworld.js

See the Docker Hub page for more details and examples.

Installation using unofficial packages

备注

The emsdk is the only officially supported way to use Emscripten that is supported by the Emscripten project, and the only one that we constantly test (emsdk CI, Emscripten GitHub CI, Chromium CI).

While we don’t officially support other ways of getting Emscripten, we definitely appreciate the efforts by third parties to package Emscripten for users’ convenience, and we’d like to help out, please get in touch if you are such a packager!

The following is a partial list of such unofficial emscripten packages:

Windows
  • package info: emscripten in chocolatey

  • maintainer: @aminya

Homebrew
Arch Linux