Hi,
I am trying to use emscripten on Windows 10.
I have an existing Javascript client application that works.
I want to connect in c++ code, and be able to call those c++ functions when
needed.
I have spent 1.5 days and can't even make a simple example work.
I am using emcc version: 2.0.25 (Online the latest version seems to be
2.0.21???)
I am using Chrome
My example:
function factorial()
{
console.log("MT:F")
Module.onRuntimeInitialized = _ => {
console.log("A")
const factorialCpp = Module.cwrap('factorial', 'number', ['number']);
console.log(factorialCpp)
var result = factorialCpp(10);
console.log(result)
};
console.log("MT:F-E")
}
When I call this function, I get only the "MT:F" and "MT:F-E", and no
errors in browser console.
My compile line:
emcc -O3 -s WASM=1 -s EXPORTED_RUNTIME_METHODS='["cwrap"]' -s
EXPORTED_FUNCTIONS="['_factorial']" factorial.cpp factorial-service.cpp -o
factorial.js
If optimization is -O0, it complains about the cwrap export
I have also tried:
function factorial2()
{
Module['onRuntimeInitialized'] = onRuntimeInitializedFactorial;
const factorialCpp = Module.cwrap('factorial', 'number', ['number']);
function onRuntimeInitializedFactorial()
{
console.log("MT:F")
console.log("A")
var result = factorialCpp(10);
console.log(result)
console.log("MT:F-E")
}
}
and:
function factorial3()
{
var factorialCpp = Module.cwrap("factorial", "number", ["number"]);
var result = factorialCpp(10);
}
Both produce an error: Uncaught TypeError: Module.cwrap is not a function
I have found over 20 examples, that say just do this or that, but nothing
works.
Maybe my environment has a config issue?
I would appreciate any any guidance on this.
Thanks,
Gary
--
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 on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/56840ae5-46b1-458d-b30f-27ee5433fd39n%40googlegroups.com.