Hello All,
I get a TypeError: Module.ClassA is not a constructor error while creating object.
I'm having a simple header class defined in header class_a.h:
and its implemetation in class_a.cpp
std::cout << "MyNamespace::ClassA constructor" << std::endl;
std::cout << "MyNamespace::ClassA::PrintName method" << std::endl;
I described in interface in class_a.idl:
Next I create glue files with:
python ${EMSCRIPTEN_ROOT}/tools/webidl_binder.py class_a.idl class_a_glue
And glue_wrapper.cpp containing
#include "class_a_glue.cpp"
Now I'd like to create bitcode
em++ class_a.cpp glue_wrapper.cpp --post-js class_a_glue.js -o class_a.bc
and finally the javascript
em++ class_a.bc -o class_a.js
Up to now everything works fine, neither error nor warning reported.
I define simle client.js script creating object and calling method:
var obj = new Module.ClassA();
When I load both class_a.jd and client.js scripts in html I get
client.js:1 Uncaught TypeError: Module.ClassA is not a constructor at client.js:1
The interesting is that, if I create javascript in one step (without intermediate .bc) then it works fine - I see proper printouts in browser console.
I'm however not likely going this way because I've got a bunch of classes I'd like to put into one javascript, e.g.
em++ class_a.cpp glue_wrapper.cpp --post-js class_a_glue.js -o class_a.bc
em++ class_b.cpp b_glue_wrapper.cpp --post-js class_b_glue.js -o class_b.bc
em++ class_c.cpp c_glue_wrapper.cpp --post-js class_c_glue.js -o class_c.bc
...
em++ class_a.bc class_b.bc class_c.bc ... -o class_a.js.
I'm using:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.35.23
clang version 3.9.0 (emscripten 1.35.23 : 1.35.23)
Why it does not work with intermediate bitcode step? Or maybe my approach is incorrect?
Best regards, Paweł