Open SamKouteili opened 1 year ago
I suspect that this is an issue that is better responded to over in the https://github.com/Snapchat/djinni repo.
It no suprise that MathUtils doesn't show up in the generated JS file though.. all that code would be in the .wasm.
What is the error you see when you try to call that function? Where are you trying to call it from?
I'm currently calling it from the following index.html
file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MyClass Test</title>
</head>
<body>
<script src="MathUtils.js"></script>
<script>
Module.onRuntimeInitialized = function() {
var instance = new Module.MathUtils();
console.log("successfully instantiated");
console.log(Module.MathUtils.addFff64(10, 8));
instance.delete();
};
</script>
</body>
</html>
And get the following error:
MathUtils.js:2182 Uncaught (in promise) BindingError: MathUtils has no accessible constructor
at ClassHandle.<anonymous> (MathUtils.js:2182:21)
at new MathUtils (MathUtils.js:1714:23)
at Module.onRuntimeInitialized (index.html:11:28)
at doRun (MathUtils.js:3963:71)
at run (MathUtils.js:3980:5)
at runCaller (MathUtils.js:3924:19)
at removeRunDependency (MathUtils.js:623:7)
at receiveInstance (MathUtils.js:842:5)
at receiveInstantiationResult (MathUtils.js:860:5)
Will be sure to also ping this to the folks at Djinni!
I'm attempting to generate a very simple
MathUtils
class with one function:add_fff64
, from c++ to JavaScript.Using Snapchat/Djinni's wasm interface, I've generated relevant binding files:
While this has indeed compiled into a JavaScript output, there is no semblance of the
MathUtils
class or anyadd_fff64
function inMathUtils.js
. Indeed, when I attempt to call theadd_fff64
function in a generic native html file, I get an error. I use the following script:This is particularly strange to me because when debugging the generated WebAssembly file with tools such as
wasm-objdump
andwasm2wat
,MathUtils
class andaddFff64
both appear, which is why I suspect this may be an issue with emscriptenIs there any way of confirming what may be the root cause of the issue?
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.45-git