mikerourke / learn-webassembly

Example code for Learn WebAssembly published by Packt.
24 stars 11 forks source link

Need update for emscripten latest(1.38.0 above) #2

Open EugeneChung opened 5 years ago

EugeneChung commented 5 years ago

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 https://github.com/emscripten-core/emscripten/pull/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
mikerourke commented 5 years ago

@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.