Compiling the C files

We need to compile each C file to a separate .wasm file, which means the command needed to perform the compilation step is verbose. To perform the build, open a terminal instance in your /parallel-wasm directory and run the following commands:

# First, compile the add.c file:
emcc -Os -s WASM=1 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 lib/add.c -o src/calc-add.wasm

# Next, compile the subtract.c file
emcc -Os -s WASM=1 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 lib/subtract.c -o src/calc-subtract.wasm

You should see two new files in the /src directory: calc-add.wasm and calc-subtract.wasm. With the required files in place, it's time to test out the application.

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

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