A simple example to create a WebAssemby code using C.
To compile, you must install Emscripten compiler.
cd ~/
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
Add variables to PATH:
source ./emsdk_env.sh
To compile the code:
emcc add.c -o add.js
This will create two files: add.js
and add.wasm
.
Install the package http-server
for the node application to be able to serve the html file:
npm install -g http-server
And start it:
http-server
Now, open the browser and access http://localhost:8080/add.html
and you will see the page.
To know more details about it, check the article here.