I'm trying to use Module.cwrap inside a new shell html file I'm calling 
new_shell.html.  

Inside this shell I added the following after the {{{ SCRIPT }}} line:
<script type='text/javascript'>
console.log("before cwrap");
var test = Module.cwrap('test', 'undefined');
console.log("after cwrap");
test();
</script>


I have a pretty simple shell.c file:
#include <emscripten.h>
#include <stdlib.h>

int main() {
printf("hello world\n");
}

void test() {
printf("button test\n");
}


I've tried several variations on emcc, but always get the same error that 
says that Module.cwrap is not a function.  Here's what I ran the most 
recent time that resulted in the Module.cwrap is not a function error:

emcc shell.c -o shell-test.html --emrun --shell-file new_shell.html -s 
NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_test', '_main']" -s 
EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap', 'ccall']"

I've seen posts that recommended changes to the quotes around 
EXTRA_EXPORTED_RUNTIME_METHODS, and I've tried many variations but nothing 
seems to work.  

Looking through the javascript file this generated "shell-test.js" it looks 
to me like as long as my script runs after this file is included the 
Module.cwrap should be there.  There is a line in that file:
Module["cwrap"] = cwrap;


I would think that this would set the cwrap function and that it would be 
available immediately after the shell-test.js is loaded, but that doesn't 
seem to be the case.

When does cwrap become available for use?

Thanks

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to