How to install the latest emscripten on Ubuntu using command line?

Solution 1:

The installation instructions suggest: download emsdk-portable.tar.gz

Unzip it, then open a terminal and run:

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

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

# Make the "latest" SDK "active"
./emsdk activate latest

see: http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html#installation-instructions for more information

Solution 2:

It is not enough to build a newer version of emscripten. You will also have to build LLVM yourself, as emscripten will complain about

CRITICAL:root:WebAssembly set as target, but LLVM has not been built with the WebAssembly backend

I got it running by following the tutorial on building LLVM at http://llvm.org/docs/GettingStarted.html and some hints from https://github.com/kripken/emscripten/wiki/New-WebAssembly-Backend

git clone http://llvm.org/git/llvm.git
git -C llvm/tools clone http://llvm.org/git/clang.git
git -C llvm/projects clone http://llvm.org/git/compiler-rt.git
git -C llvm/projects clone http://llvm.org/git/openmp.git
git -C llvm/projects clone http://llvm.org/git/libcxx.git
git -C llvm/projects clone http://llvm.org/git/libcxxabi.git
mkdir llvmbuild
cd llvmbuild
cmake -G "Unix Makefiles" \
      -DLLVM_ENABLE_PROJECTS="llvm/tools/clang;llvm/projects/libcxx;llvm/projects/libcxxabi" \
      -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \
      -DCMAKE_BUILD_TYPE=Release \
      ../llvm
make all
cd ..

And then following the tutorial on building emscripten at http://webassembly.org/getting-started/developers-guide/

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install sdk-incoming-64bit binaryen-master-64bit
./emsdk activate sdk-incoming-64bit binaryen-master-64bit
source ./emsdk_env.sh
cd ..

# configure emscripten to use self-built LLVM
cat ~/.emscripten \
    | sed "s:LLVM_ROOT=[^\n]*:LLVM_ROOT='${PWD}/llvmbuild/bin':g" \
    > ~/.emscripten.tmp
mv ~/.emscripten ~/.emscripten.bak
mv ~/.emscripten.tmp ~/.emscripten

Solution 3:

From the emscripten's doc page [ from the ground zero ]

1. Get the emsdk repo

git clone https://github.com/emscripten-core/emsdk.git

2. Enter that directory

cd emsdk

3. Download and install the latest SDK tools

./emsdk install latest

4. Make the "latest" SDK "active"

./emsdk activate latest

5. Activate PATH and other environment variables

source ./emsdk_env.sh

these variables are set for the current terminal, if you want to make it for everybody, so you can put into any terminal profile. Here they are:

The environment variables:

EMSDK = < path to emsdk dir >

EM_CONFIG = ~/.emscripten

EMSDK_NODE = < path to emsdk dir >/node/12.9.1_64bit/bin/node

6. Now just try it!

emcc