wasmerio / wasmer-java

☕ WebAssembly runtime for Java
https://medium.com/wasmer/announcing-the-first-java-library-to-run-webassembly-wasmer-jni-89e319d2ac7c
MIT License
593 stars 55 forks source link

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. #68

Open ZZK-AJ opened 2 years ago

ZZK-AJ commented 2 years ago

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.wasmfile. and I run the.wasmfile like thiswasmtime 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 filesimple.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.