Have you done any web application work with a WebAssembly? It gets you being able to bring your C or C++ or Rust code into a web application. Great idea, huh?! Today we’re presenting some simple usages of a WebAssembly made via two small pieces of C code …
- WebAssembly of “Hello World” via hello.c C code generating …
- hello.html
- hello.js
- hello.wasm
… via Emscripten … thanks
- WebAssembly of Fibonacci series fibonacci.html via main.c C code generating …
To get started, and going, here, we liked Compiling a New C/C++ Module to WebAssembly as far as advice goes and needed Emscripten download resources at Emscripten Download and install and CMake on our macOS local environment, allowing us to compile the html via a command such as …
emcc hello.c -o hello.html
… allowing the sftp of the html and js and wasm over to the RJM Programming public web domain, and show you, in action, today. Cute, huh, given the code is C by nature and inclination!
Word of warning with the Fibonacci code is that use of C scanf function is a little sketchy in its behaviour, hence our wrapping of the Emscripten html within an iframe, where topmost parent html explains the issue, a bit.
If this was interesting you may be interested in this too.