Prerequisites
- Node.js (tested with v14.18.2)
- Emscripten SDK with
emccavailable in yourPATH
Before you begin, make sure you’ve installed Node.js and set up the Emscripten SDK.
Run
Run
emcc --version to verify your installation.1. Write the C Source
Create a file namedhelloworld.c with the following contents:
2. Compile to WASM for Node.js
Use Emscripten’semcc compiler to generate both the WebAssembly binary and the JavaScript loader:
The top of
helloworld.js looks like this: