You can find the final code on my github with some samples and the scripts to compile the library.
Some tips I learned during this toy project..
- try to compile the library with clang before using emscripten, and patch everything to make it compile. Much of libraries are made to compile with gcc and not tested with other compilers, so possibly you may have to patch some lines of code. Here is my patch. basically disable float stuff and warning on configure script file
- convert the library itself and use it on your js code, that is much faster than the previous approach but you will have to manage with memory allocations and need a better understanding of how emscripten and memory works.
Finally here is my notes, with a bit more detail of how it was done and the problems on the way. libcaca.js - raw notes