Friday, 17 March 2017

compile hello world to wasm and run in node

I am trying to run a webassembly module in node.js and I'm getting a Wasm decoding failedResult. I think that my problem is transforming the node Buffer into an ArrayBuffer. Here is my applicable code:

fs.readFileAsync( WASM_PATH )
  .then( buf => buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) )
  .then( arrayBuffer => Wasm.instantiateModule(arrayBuffer) )
  .then( results => console.log(results.instance) )
  .catch( err => console.error(err) );

I get this error:

(relevant details) 

Wasm decoding failedResult = expected version 0c 00 00 00, found 01 00 00 00 @+4

When I use emcc hello_world.c -s WASM=1 -o hello.html I can load the module and run it in browser. So, I'm pretty sure this is a problem on my end or perhaps some compatibility issue. Thanks in advance.



via slmyers

No comments:

Post a Comment