Installation of WebAssembly on Windows and first program
How to make your first program in wasm (from C++ source code)
Install Emscriptem on Windows
Download it here: emscripten.org or download directly the zip file on github.
The bad news is that now you have to use Python to install Emscriptem, 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).
Type:
./emsdk update
./emsdk install latest
./emsdk activate latest
On Windows, the Emscriptem 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 ...