You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've had no luck yet running a test wasmer-java project using .wasm files built from C/C++. The included examples with wasmer-java work fine, but anything that I've built either via emscripten or wasienv throws RuntimeExceptions with missing imports:
Additional details
a C program built using wasienv, the .wasm file runs fine when executed: wasmer run example.wasm -- DataInput
But when testing in wasmer-java I get this error: Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: 9 link errors: (1 of 9) Import not found, namespace: wasi_unstable, name: fd_prestat_get (2 of 9) Import not found, namespace: wasi_unstable, name: fd_prestat_dir_name (3 of 9) Import not found, namespace: wasi_unstable, name: proc_exit (4 of 9) Import not found, namespace: wasi_unstable, name: fd_fdstat_get (5 of 9) Import not found, namespace: wasi_unstable, name: fd_close (6 of 9) Import not found, namespace: wasi_unstable, name: args_sizes_get (7 of 9) Import not found, namespace: wasi_unstable, name: args_get (8 of 9) Import not found, namespace: wasi_unstable, name: fd_seek (9 of 9) Import not found, namespace: wasi_unstable, name: fd_write at org.wasmer.Instance.nativeInstantiate(Native Method) at org.wasmer.Instance.<init>(Instance.java:45) at Example.main(simple.java:18)
Additionally, a C++ project built using emscripten via JS: em++ hello.cpp fib.cpp -s STANDALONE_WASM -s ALLOW_MEMORY_GROWTH=0 -s EXPORTED_FUNCTIONS="[_new_fib, _next_val]" -Wl, --no-entry -o hello.js || exit 1
Runs fine in the browser with javascript but when tested in wasmer-java I get this error: Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: link error: Import not found, namespace: wasi_snapshot_preview1, name: proc_exit at org.wasmer.Instance.nativeInstantiate(Native Method) at org.wasmer.Instance.<init>(Instance.java:45) at Example.main(simple.java:18)
Is there an import step I'm missing? Or a build sequence I need to follow? I've based the java code on the examples and it breaks at the instantiation point,:
`Path wasmPath = Paths.get(new Example().getClass().getClassLoader().getResource("hello.wasm").getPath())
// Reads the WebAssembly module as bytes.
byte[] wasmBytes = Files.readAllBytes(wasmPath);
// Instantiates the WebAssembly module.
Instance instance = new Instance(wasmBytes);`
The wasmer-jni*.jar is in the classpath. I'm running this on Linux Ubuntu. Both emscripten and wasienv are the most recent versions as of this question's posting.
Thanks for any help, I'd love to use WASM and Java if possible.
The text was updated successfully, but these errors were encountered:
The more I look into this it appears this may be related to an already open issue: #11
I haven't found a way yet to build .wasm files from C/C++ without an import line so this would be a very nice enhancement. Thanks for the work you all have put in to this project.
Summary
I've had no luck yet running a test wasmer-java project using .wasm files built from C/C++. The included examples with wasmer-java work fine, but anything that I've built either via emscripten or wasienv throws RuntimeExceptions with missing imports:
Additional details
a C program built using wasienv, the .wasm file runs fine when executed:
wasmer run example.wasm -- DataInput
But when testing in wasmer-java I get this error:
Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: 9 link errors: (1 of 9) Import not found, namespace: wasi_unstable, name: fd_prestat_get (2 of 9) Import not found, namespace: wasi_unstable, name: fd_prestat_dir_name (3 of 9) Import not found, namespace: wasi_unstable, name: proc_exit (4 of 9) Import not found, namespace: wasi_unstable, name: fd_fdstat_get (5 of 9) Import not found, namespace: wasi_unstable, name: fd_close (6 of 9) Import not found, namespace: wasi_unstable, name: args_sizes_get (7 of 9) Import not found, namespace: wasi_unstable, name: args_get (8 of 9) Import not found, namespace: wasi_unstable, name: fd_seek (9 of 9) Import not found, namespace: wasi_unstable, name: fd_write at org.wasmer.Instance.nativeInstantiate(Native Method) at org.wasmer.Instance.<init>(Instance.java:45) at Example.main(simple.java:18)
Additionally, a C++ project built using emscripten via JS:
em++ hello.cpp fib.cpp -s STANDALONE_WASM -s ALLOW_MEMORY_GROWTH=0 -s EXPORTED_FUNCTIONS="[_new_fib, _next_val]" -Wl, --no-entry -o hello.js || exit 1
Runs fine in the browser with javascript but when tested in wasmer-java I get this error:
Exception in thread "main" java.lang.RuntimeException: Failed to instantiate the module: link error: Import not found, namespace: wasi_snapshot_preview1, name: proc_exit at org.wasmer.Instance.nativeInstantiate(Native Method) at org.wasmer.Instance.<init>(Instance.java:45) at Example.main(simple.java:18)
Is there an import step I'm missing? Or a build sequence I need to follow? I've based the java code on the examples and it breaks at the instantiation point,:
`Path wasmPath = Paths.get(new Example().getClass().getClassLoader().getResource("hello.wasm").getPath())
// Reads the WebAssembly module as bytes.
byte[] wasmBytes = Files.readAllBytes(wasmPath);
The wasmer-jni*.jar is in the classpath. I'm running this on Linux Ubuntu. Both emscripten and wasienv are the most recent versions as of this question's posting.
Thanks for any help, I'd love to use WASM and Java if possible.
The text was updated successfully, but these errors were encountered: