Hello emscripten experts, I noticed a strange behavior when using or not using the memory-init-file for my c++ project based on the webidl_binder. Everything works fine, when this option is set to 1. However, including the initialization data into the generated JavaScript file seems to break the onRuntimeInitialized mechanism somehow, that is, my JavaScript init function, which accesses the compiled objects is called too early (it works when I use something like setTimeout(init, 500)).
*emcc -v:* emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.34.1 clang version 3.7.0 (https://github.com/kripken/emscripten-fastcomp-clang d0bf104be3b7fb821711438ab9a26dabc3bc6cd9) (https://github.com/kripken/emscripten-fastcomp 6ce52965507b262417a7e815fd46e8e92f351b12) Target: x86_64-unknown-linux-gnu Thread model: posix Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.1 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Candidate multilib: .;@m64 Selected multilib: .;@m64 INFO root: (Emscripten: Running sanity checks) *Minimal (not) working example:* *foo.cpp:* #include <stdio.h> #include "foo.h" Foo::Foo() { printf("Constructor of Foo\n"); } #include "glue.cpp" *foo.h:* class Foo { public: Foo(); }; *foo.idl:* interface Foo { void Foo(); }; *foo.html:* <!DOCTYPE html> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <TITLE>Foo</TITLE> </HEAD> <BODY> <DIV> <script> function init() { new Module.Foo() } var Module = { onRuntimeInitialized: function() { init(); } //onRuntimeInitialized: function() { setTimeout(init, 500); } <== works }; </script> <script type="text/javascript" src="foo.js"></script> </DIV> </BODY> </HTML> *Build flow:* python ${EMSCRIPTEN}/tools/webidl_binder.py foo.idl glue emcc foo.cpp --post-js glue.js -o foo.js --memory-init-file 1 => switching the --memory-init-file option from 1 to 0 makes "new Module.Foo()" fail => error occurs for all optimization levels => also adding a main function calling init() through EM_ASM to the c++ class fails Any idea how I can include the memory initialization into the JS? Thank you very much! Christian -- 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 emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.