Skip to content
Shyam Saladi edited this page Oct 30, 2019 · 6 revisions

Insights from porting anhmm to web assembly

  • Make sure the code is C99 compatible

    • Implicit function definitions aren't supported so add function declarations

    • Fix all other compiler warnings

  • Can just change CC from whatever it is (e.g. cc or gcc) to emcc. This results in files with the names of the original binaries, but are actually object files

  • Link/rename this file and turn it into wasm using emcc, e.g.

  • multiple spaces are displayed as one in html (have to convert to &nbsp)

Filesystem support

  • There are 2 main methods of Packaging Files

    • Compile time packaging: Useful for including static files. More information here

    • Runtime file inclusion: Useful for letting user upload files during runtime.

      • First, get the files using an HTML input field

      • Base64 encode the file. Example here

      • Use the FS_createDataFile function to add the file to the module before running it

ln -s decodeanhmm decodeanhmm.o && emcc decodeanhmm.o -o project.html

Potentially useful reference material

Clone this wiki locally