Hello,
The following example does
- not work with current emcc 4.0.18 in Chrome.
It
- works with current emcc 4.0.18 in Firefox and it
- works with emcc 4.0.16 in Chrome.
I use local files on Windows 11.
Example index.html:
<!DOCTYPE html>
<html>
<head>
<script>
function compute() {
a=parseFloat(document.getElementById('a').value);
b=parseFloat(document.getElementById('b').value);
document.getElementById('c').innerText = Module.Sum(a, b);
}
</script>
<script src="Sum.js"></script>
</head>
<body>
<input id="a" type="number" onchange="compute()">
<input id="b" type="number" onchange="compute()">
<div id="c">Result</div>
</body>
</html>
Example Sum.cpp:
#include <emscripten/bind.h>
double Sum(double a, double b) {
return a+b;
}
EMSCRIPTEN_BINDINGS(Module) {
emscripten::function("Sum", &Sum);
}
Compile with:
emcc -o Sum.js Sum.cpp -sSINGLE_FILE --bind -sASSERTIONS
Error in Chrome Console:
failed to asynchronously prepare wasm: CompileError:
WebAssembly.instantiate(): section was shorter than expected size (18371
bytes expected, 207 decoded) @+219
instantiateArrayBuffer @ Sum.js:634
await in instantiateArrayBuffer
instantiateAsync @ Sum.js:645
createWasm @ Sum.js:713
(anonymous) @ Sum.js:2761Understand this error
Sum.js:275 Uncaught (in promise) TypeError: filename.startsWith is not a
function
isFileURI @ Sum.js:275
instantiateArrayBuffer @ Sum.js:637
await in instantiateArrayBuffer
instantiateAsync @ Sum.js:645
createWasm @ Sum.js:713
(anonymous) @ Sum.js:2761Understand this error
Sum.js:794 still waiting on run dependencies:
(anonymous) @ Sum.js:794
setInterval
addRunDependency @ Sum.js:784
createWasm @ Sum.js:674
(anonymous) @ Sum.js:2761Understand this error
Sum.js:796 dependency: wasm-instantiate
(anonymous) @ Sum.js:796
setInterval
addRunDependency @ Sum.js:784
createWasm @ Sum.js:674
(anonymous) @ Sum.js:2761Understand this error
Sum.js:799 (end of list)
(anonymous) @ Sum.js:799
setInterval
addRunDependency @ Sum.js:784
createWasm @ Sum.js:674
(anonymous) @ Sum.js:2761Understand this error
What am I doing wrong?
Thanks for your help!
Thomas
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/emscripten-discuss/504419d6-cdcf-4eec-9a1e-e7f69f87a129n%40googlegroups.com.