September 2018
Intermediate to advanced
328 pages
9h 10m
English
If you specify an HTML file extension (for example, -o with-glue.html) for the output, you'll end up with a with-glue.html, with-glue.js, and with-glue.wasm file (assuming you also specified -s WASM=1). If you have a main() function in the source C/C++ file, it'll execute that function as soon as the HTML loads. Let's compile our example C code to see this in action. To compile it with the HTML file and JavaScript glue code, cd into the /chapter-05-create-load-module folder and run the following command:
emcc with-glue.c -O3 -s WASM=1 -s USE_SDL=2 -o with-glue.html
The first time you run this command, Emscripten is going to download and build the SDL2 library. It could take several minutes to complete this, ...
Read now
Unlock full access