- emscripten.org
- github: emscripten-core
- emscripten: download
- github: Emscripten SDK
cd ~/.local/share
git clone https://github.com/emscripten-core/emsdk.git
# delete:
# rm -rf ~/.local/share/emsdk
# ~/.zshrc
export PATH="$PATH:$HOME/.local/share/emsdk"
export EMSDK_QUIET=1
source $HOME/.local/share/emsdk/emsdk_env.sh
emsdk list
emsdk install emscripten-main-64bit binaryen-main-64bit
emsdk activate emscripten-main-64bit binaryen-main-64bit
emsdk list
The following tools can be compiled from source:
(*) emscripten-main-64bit INSTALLED
(*) binaryen-main-64bit INSTALLED
Items marked with * are activated for the current user.
Items marked with (*) are selected for use, but your current shell environment is not configured to use them. Type "source ./emsdk_env.sh" to set up your current shell to use them.
emsdk help
emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.35-git (de7cbc56c3ac38b83cc3e8bbc17ac5fbb6b3bbd7)
Ubuntu clang version 17.0.0 (++20230326042432+943df86c82b1-1~exp1~20230326042544.827)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/bin
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
emcc main.c
helloworld/
├── a.out.js
├── a.out.wasm
└── main.c
0 directories, 3 files
Run Javascript:
node a.out.js
Hello, World!
emcc main.c -o index.html
Run a Local Server: localhost:8000
python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [24/Feb/2023 20:53:00] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Feb/2023 20:53:00] "GET /index.js HTTP/1.1" 200 -
127.0.0.1 - - [24/Feb/2023 20:53:00] "GET /index.wasm HTTP/1.1" 200 -