WebAssembly demo with Fibonacci numbers in C++
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Readme.md
container.html
fibonacci.cpp
formdata.js
style.css

Readme.md

WebAssembly Demo Project

This project calculates Fibonacci numbers in C++ and JavaScript, using two different algorithms, and measures performance.

  • fibonacci.cpp: C++ code, can be compiled with Emscripten/Clang, c++ or (possibly) other C++ compilers
  • container.html: HTML shell for Emscripten compilation
  • formdata.js: Script required by container.html
  • style.css: CSS required by container.html

This project can be compiled with Emscripten using the following command (Windows syntax):

emcc fibonacci.cpp -s "EXPORTED_FUNCTIONS=['_fibstring']" -s "EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap']" -O3 --shell-file container.html -o fibonacci.html

Linux syntax:

emcc fibonacci.cpp -s EXPORTED_FUNCTIONS='["_fibstring"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -O3 --shell-file container.html -o fibonacci.html

This project was created as demo for a tutorial in c't Magazin, autumn 2018.