wasmer-java icon indicating copy to clipboard operation
wasmer-java copied to clipboard

Run the .wasm file I compiled that make a problem. I want to know the author of this project compile the rust to .wasm file.

Open ZZK-AJ opened this issue 3 years ago • 0 comments

Summary

I use the code like the tutorial , #[no_mangle] pub extern fn sum(x: i32, y: i32) -> i32 { x + y } and use: cargo build --target=wasm32-wasi to compile my rust code to .wasm file. and I run the .wasm file like this wasmtime hello-rust2wasm.wasm, it can worked. but when I call the .wasm file in Java it comes an error. Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: Error while importing "wasi_snapshot_preview1"."fd_write": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] }) but if I use the author's file simple.wasm show in README. it can work.

so I want to know how the author compiles the rust to wasm and where I can learn the method.

Additional details

Provide any additional details here.

ZZK-AJ avatar Jul 14 '22 14:07 ZZK-AJ