webaudiomodules / webdx7

virtual Yamaha DX7 synth
https://webaudiomodules.org/wamsynths/dx7
MIT License
139 stars 24 forks source link

TypeError: WAM.cwrap is not a function #5

Open simdax opened 5 years ago

simdax commented 5 years ago

Hello

The synth is working with the predefined files in dist/dx7/wasm of the repo, But after build I have this error image

I'm building like it

emmake make
node encode-wasm.js dx7.wasm
cp dx7*.js ../dist/dx7/wasm
cd ../dist && http-server

and strangely the wasm module seems quite complete

image

jariseon commented 5 years ago

cool, you are almost there. try adding

-s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']"

to JSFLAGS in the makefile. Emscripten toolchain slimmed down its footprint a while back, and one of the things it dropped was cwrap. thanks for raising an issue, will modify makefile in the repo asap.

bfabricius commented 5 years ago

Hey guys thanks for pointing this out here, i got similar issues when trying to run webOBXD. Ill try to sort them out by the indicated way.

simdax commented 5 years ago

Cool, but now the error changed ?

image

and with ASSERTIONS=1 I have that, but I have added the extra runtime functions...

image

and the module looks quite the same

image

jariseon commented 5 years ago

ah, one more fix: pls replace the line at https://github.com/webaudiomodules/webdx7/blob/master/src/c/dx7.cc#L15

with this: extern "C" { EMSCRIPTEN_KEEPALIVE void* createModule() { return new DX7(); } }

emscripten linker drops unreferenced symbols to minimize its output footprint. since this method is called from JS, the linker does not know that the method is important for us. EMSCRIPTEN_KEEPALIVE directive forces linking, and as a result createModule function will be added to the JS module file.

simdax commented 5 years ago

ok we're getting closer ! :)

Now I have image

And note now I'm using emrun instead of http-server

prateek-rajdev commented 4 years ago

Hi, @simdax I also came across these problems, were you able to get it working? I am getting this "Uncaught (in promise) undefined" error.

Thanks :)

micahscopes commented 3 years ago

@prateek-rajdev, @simdax:

I bumped into this issue with recent versions of emscripten, and needed to explicitly add a few functions to the EXPORTED_RUNTIME_METHODS option, like this: -s "EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'setValue']"

I also needed to make some additional changes to get everything working. Recent versions of emscripten prohibit . characters in EXPORT_NAME, so I had to work around that too, along with a few other things.

You can see all the Makefile changes here

prateek-rajdev commented 3 years ago

@micahscopes Thanks a lot :)

mrkev commented 7 months ago

@micahscopes (and others). I created a PR in emscripten to address the EXPORT_NAME error. Feel free to comment: https://github.com/emscripten-core/emscripten/pull/21115