NonBinary Posted October 3, 2018 Share Posted October 3, 2018 I'm new to emscripten and find it very hard... I have obligation to work on windows because i have to test .exe versions of my apps. I'm on windows 7. I can compile wasm but javascript cannot read it. Here's my code. C code: char * HelloWorld () { return "Hello World !"; } Emscripten command-line: emcc hello.c -O2 -s ONLY_MY_CODE=1 -s WASM=1 -s SIDE_MODULE=1 -s EXPORTED_FUNCTIONS="['_HelloWorld']" -o hello.wasm Wat result: (module (type $t0 (func (result i32))) (type $t1 (func)) (import "env" "memory" (memory $env.memory 256)) (import "env" "memoryBase" (global $env.memoryBase i32)) (func $_HelloWorld (export "_HelloWorld") (type $t0) (result i32) (get_global $env.memoryBase)) (func $__post_instantiate (export "__post_instantiate") (type $t1) (set_global $g1 (i32.add (get_global $env.memoryBase) (i32.const 16))) (set_global $g2 (i32.add (get_global $g1) (i32.const 5242880)))) (global $g1 (mut i32) (i32.const 0)) (global $g2 (mut i32) (i32.const 0)) (data (get_global $env.memoryBase) "Hello World !")) Javascript: importObject = {}; fetch('hello.wasm').then(response => response.arrayBuffer() ).then(bytes => WebAssembly.instantiate(bytes, importObject) ).then(results => { console.log("loaded"); }); Error message: Uncaught (in promise) TypeError: Import #0 module="env" error: module is not an object or function Promise.then (async) (anonymous) @ (index):9 Can you tell me what's wrong in my code ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.