Wasm Builders

Ajay Kumar
Ajay Kumar

Posted on • Updated on

Printing hello using a default template, generated while compiling with Emscripten

Steps to launch an Emscripten-generated HTML page

Write a C/C++ program

int main(){
printf("Hello Ajay\n");
return 0;

Compile the program using the following command

emcc hello.c -s WASM=1 -o index.html

This will generate three files. A HTML file to show our content, wasm file which will have our logic, and a JS file which will help us load that wasm file into the browser.

Serve an Emscripten HTML page

emrun --no_browser --port 8080 index.html

This will start a http server at localhost port 8080


Discussion (0)