使用group.cloneAsImage(image => {
image.set({...do settings});
canvas.add(image);
});
(C)编译C / C ++ .wasm代码时-在Chrome中加载并运行良好,但是使用clang
(C ++)时-wasm加载失败并出现错误(在JS中)控制台):
clang++
为什么?
WASM编译参数:
Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #1 module="wasi_snapshot_preview1" function="fd_close" error: function import requires a callable
JS wasm加载代码:
"clang", <=== I only changed this to "clang++" - and it fails
"-O0",
// "-std=c++14",
"--target=wasm32-unknown-wasi",
"--sysroot C:\\OpenGL\\wasi-sdk-11.0-mingw.tar\\wasi-sdk-11.0\\share\\wasi-sysroot",
"-fno-exceptions",
"-nostartfiles",
"-Wl,--import-memory",
"-Wl,--no-entry",
"-Wl,--export-all",
"-o templates/my-app/public/hello_wasm.wasm",
"wasm/hello_wasm.cpp"
hello_wasm.cpp(编译没有错误):
const response = await fetch("./hello_wasm.wasm");
const bytes = await response.arrayBuffer();
const { instance } = await WebAssembly.instantiate(bytes, {
env: { memory: this.memory },
},
});
this.instance = instance;
console.log("c" + instance);
})();
LLVM v10 我使用https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-mingw.tar.gz
中的wasi sysroot 讨论此问题答案 0 :(得分:0)
为了在Web上运行WASI二进制文件,您需要提供WASI API的实现。 Web平台本身不支持WASI。有一些polyfill尝试模拟某些/所有可能适用于您的案例的WASI API。