mikerourke/learn-webassembly

Need update for emscripten latest(1.38.0 above)

Opened this issue · 1 comments

As #1 indicated, the examples of the master branch are not working with the emscripten 1.38.0 above. (For me, 1.38.30)

I made them work like below;

  1. Modify common/load-wasm.js as emscripten-core/emscripten#7467 said.
  2. Specify emcc EXPORTED_FUNCTIONS option
    https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-compiled-c-functions-from-javascript-using-ccall-cwrap
    For chapter-05-create-load-module as instance,
    emcc .\without-glue.c -Os -s WASM=1 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 -s EXPORTED_FUNCTIONS='["_init", "_setIsRunning", "_getIsRunning", "_updateRectLocation", "_moveRect"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o without-glue.wasm

@EugeneChung I know this is a late response, but I can't make any changes to the repo since the book was released. The book was updated to indicate the specific version of Emscripten I was using (prior to the breaking changes). Thanks for providing directions on how to get the code working with the newer version. I'm going to leave this issue open for reference.