Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: WAM.cwrap is not a function #5

Open
simdax opened this issue Oct 10, 2018 · 9 comments
Open

TypeError: WAM.cwrap is not a function #5

simdax opened this issue Oct 10, 2018 · 9 comments

Comments

@simdax
Copy link

simdax commented Oct 10, 2018

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
Copy link
Member

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
Copy link

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
Copy link
Author

simdax commented Oct 11, 2018

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
Copy link
Member

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
Copy link
Author

simdax commented Oct 11, 2018

ok we're getting closer ! :)

Now I have
image

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

@prateek-rajdev
Copy link

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
Copy link
Contributor

micahscopes commented Aug 4, 2021

@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
Copy link

@micahscopes Thanks a lot :)

@mrkev
Copy link

mrkev commented Jan 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants