-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Help compiling and executing functions #23350
Comments
There are docs on the various different ways you can interact with your module here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html. The most simple ways is to simple call your exported functions directly via e.g. |
I got it working, but I've noticed something weird about it... Edit: Seems like it's not the first function, but one specifically, for no apparent reason... |
This is because the wasm module is instantiated asynchronously. So at that point where the code above is run the exports (in your case However you need to be carefull not to try to call any of these function until the module is actually ready. See https://emscripten.org/docs/api_reference/module.html#Module.onRuntimeInitialized. You can also opt out of async compilation in some cases if you prefer: https://emscripten.org/docs/tools_reference/settings_reference.html#wasm-async-compilation BTW, f you want to ready the generated output you can can link without optimizations or add (BTW, when filing bugs like this its easier for us if you can copy and paste the text into github rather than attaching screenshots) |
Also, what version of emscripten are you using? |
Hi, I've been trying to compile a cpp into wasm, in this case using SINGLE_FILE option.
It generates a JS file that loads the WASM from a BASE64 string, which is what I want.
Since my project can only have a single JS file, I've copied and pasted the Emscripten js code at the top of my main js file.
But I have no clue on how to call the C/C++ functions from it, of if I'm even getting the code to execute at all...
Can you guys please help me with a basic example?
I can't find anything on the subject on the internet, information about it is very escarce...
The text was updated successfully, but these errors were encountered: