I am working on windows 10. And I want to compile a C++ file  to wasm. This 
C++ code call function from a static library.

I compile the file with this command line :emcc cppfile.cpp -Os -s WASM=1 
-s SIDE_MODULE=1 -o cppfile.wasm -s RUNTIME_LINKED_LIBS=['library.lib']  -I 
"F:/wzm/MonoProject/include"

I load the wasm file with this code :

function loadWebAssembly(filename, imports = {}) {
  return fetch(filename)
    .then(response => response.arrayBuffer())
    .then(buffer => WebAssembly.compile(buffer))
    .then(module => {
      imports.env = imports.env || {}
      Object.assign(imports.env, {
        memoryBase: 0,
        tableBase: 0,
        memory: new WebAssembly.Memory({ initial: 256, maximum: 256 }),
        table: new WebAssembly.Table({ initial: 0, maximum: 0, element: 
'anyfunc' })
      })
      return new WebAssembly.Instance(module, imports)
    })
}

But when I load the wasm file , the console return me a error:
Uncaught (in promise) LinkError: WebAssembly Instantiation: Import #1 
module="env" function="_mono_class_get_method_from_name" error: function 
import requires a callable
    at fetch.then.then.then.module (http://localhost:8000/loader.js:13:14)
    at <anonymous>

It mean I don't link the library.
How to link the static library?

-- 
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