WebAssembly.fr/en/

Installation of WebAssembly on Windows and first program

How to make your first program in wasm (from C++ source code)

Install Emscripten on Windows

Download it here: emscripten.org or download directly the zip file on github.

You can also install it more simply using this command:

git clone https://github.com/emscripten-core/emsdk.git 

The bad news is that now you have to use Python to install Emscripten, for some reason, which was not the case before.

Open the Powershell command line window, preferably, which is the default console on Windows 10, and go to the emsdk-master directory (you can also rename it to emsdk for simplicity).

To be able to use the compiler in another directory, type:

emsdk_env.bat 

You will need to add this script to the Windows startup process so that the compiler remains accessible in future sessions.

Type:

./emsdk update
./emsdk install latest
./emsdk activate latest

On Windows, the Emscripten archive includes the CLang compiler, Python, and Node.js the JavaScript interpreter among others.

If you have already installed a newer version of Node.js, remove the EMSDK_NODE entry in the PATH environment variable.

Test the configuration

A minimal C++ program to compile in wasm...

#include <stdio.h>

int main() {
  printf("Hello, world!\n");
  return 0;
}

Save this program in a file named hello.cpp

Type:

emcc hello.cpp

Then run the program just generated:

node a.out.js

This will display: Hello, World!

To use you script in a browser, use the following command:

emcc hello.cpp -o hello.html

An HTML file is also generated which contains the code necessary to call the wasm code online ...