Compiling the example C code

Now that we have our C code written, we'll need to compile it. One of the required flags you must pass to the emcc command is -o <target>, where <target> is the path to the desired output file. The extension of that file will do more than just output that file; it impacts some of the decisions the compiler makes. The following table, taken from Emscripten's emcc documentation at http://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html#emcc-o-target, defines the generated output types based on the file extension specified:

Extension Output
<name>.js

JavaScript glue code (and .wasm if the s WASM=1 flag is specified).

<name>.html

HTML and separate JavaScript file (<name>.js). Having the separate JavaScript file improves page load time.

<name>.bc

LLVM bitcode (default).

<name>.o

LLVM bitcode (same as .bc).

<name>.wasm

Wasm file only (with flags specified from Chapter 4, Installing the Required Dependencies).

 

You can disregard the .bc and .o file extensions—we won't need to output LLVM bitcode. The .wasm extension isn't on the emcc Tools Reference page, but it is a valid option if you pass the correct compiler flags. These output options factor into the C/C++ code we write.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset