September 2018
Intermediate to advanced
328 pages
9h 10m
English
In order to compile a C/C++ file with Emscripten, we'll use the emcc command. We need to pass some arguments to the compiler to ensure we get a valid output that we can utilize in the browser. To generate a Wasm file from a C/C++ file, the command follows this format:
emcc <file.c> -Os -s WASM=1 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 -o <file.wasm>
Here's a breakdown of each of the arguments for the emcc command:
| Argument | Description |
| <file.c> | Path of the C or C++ input file that will be compiled down to a Wasm module; we'll replace this with the actual file path when we run the command. |
| -Os | Compiler optimization level. This optimization flag allows for module instantiation without requiring Emscripten's ... |
Read now
Unlock full access