googlecodelabs / web-assembly-introduction

Introduction to Web Assembly
Apache License 2.0
27 stars 9 forks source link

'addOnPostRun' was not exported #5

Open jepiqueau opened 6 years ago

jepiqueau commented 6 years ago

getting the following error when serving the Mandelbrot-simple or the Mandelbrot-tiles after running make: 'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ) mandelbrot.js:4244 'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ) abort @ mandelbrot.js:4244 mandelbrot.js:4260 Uncaught abort("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") at Error at jsStackTrace (http://192.168.1.78:5000/mandelbrot.js:999:13) at stackTrace (http://192.168.1.78:5000/mandelbrot.js:1016:12) at abort (http://192.168.1.78:5000/mandelbrot.js:4254:44) at Object.Module.addOnPostRun (http://192.168.1.78:5000/mandelbrot.js:4056:68) at http://192.168.1.78:5000/:24:16 mandelbrot.js:1624 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'. (anonymous) @ mandelbrot.js:1624 mandelbrot.js:1625 falling back to ArrayBuffer instantiation (anonymous) @ mandelbrot.js:1625

sean-dougherty commented 5 years ago

I was able to fix this by modifying the Makefile to specify addOnPostRun in EXTRA_EXPORTED_RUNTIME_METHODS:

export EMCC_DEBUG=1

mandelbrot.js: mandelbrot.cpp Makefile
        em++ --bind --std=c++11 mandelbrot.cpp -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun'] -o\
 mandelbrot.js

clean:
        rm *.js *.wasm
loretoparisi commented 3 years ago

hey @sean-dougherty I had the same problem in this webassembly module, I have added as you suggest the flag -s EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun'], but it does not work in this case:

EMCXXFLAGS = --bind --std=c++11 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun', 'FS']" -s "DISABLE_EXCEPTION_CATCHING=0" -s "EXCEPTION_DEBUG=1" -s "FORCE_FILESYSTEM=1" -s "MODULARIZE=1" -s "EXPORT_ES6=1" -s 'EXPORT_NAME="FastTextModule"' -s "USE_ES6_IMPORT_META=0" -s EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun'] -Isrc/

I'm still getting the same error:

/Users/loretoparisi/Documents/Projects/wasm/fasttext_wasm.js:230
      throw ex;
      ^

TypeError: fastTextModule.addOnPostRun is not a function

More info on SF here.