Setting up Emscripten with CMake on Linux
Setting up Emscripten with CMake on Linux is largely the same as the earlier instructions for Setting up Emscripten with CMake in Git Bash on Windows 10. The steps about creating Python aliases can be skipped, since they only apply to Git Bash. The rest is then the same, since using Git Bash means we can use the Linux commands.
As a quick refresher, assuming you have a git repository with emsdk as a submodule, the steps for getting started on Linux are as follows:
Ensure the emsdk submodule is up-to-date §
git submodule update --init --recursive
Install and activate emsdk §
$ cd modules/emsdk/ $ ./emsdk install latest $ ./emsdk activate latest Resolving SDK alias 'latest' to '3.1.8' Resolving SDK version '3.1.8' to 'sdk-releases-upstream-8c9e0a76ebed2c5e88a718d43e8b62452def3771-64bit' Setting the following tools as active: node-14.18.2-64bit releases-upstream-8c9e0a76ebed2c5e88a718d43e8b62452def3771-64bit Next steps: - To conveniently access emsdk tools from the command line, consider adding the following directories to your PATH: /home/sam/projects/MyProject/modules/emsdk /home/sam/projects/MyProject/modules/emsdk/node/14.18.2_64bit/bin /home/sam/projects/MyProject/modules/emsdk/upstream/emscripten - This can be done for the current shell by running: source "/home/sam/projects/MyProject/modules/emsdk/emsdk_env.sh" - Configure emsdk in your shell startup scripts by running: echo 'source "/home/sam/projects/MyProject/modules/emsdk/emsdk_env.sh"' >> $HOME/.bash_profile
Perform the build §
As before, each time you open a new shell, you will need to
source ./emsdk_env.sh so that tools such as
emcmake are on the path.
Then you can build the project as follows:
emcmake cmake -S . -B build-em cmake --build build-em