wasmer-c-api
wasmer-c-api copied to clipboard
Non-WASI example fails due to imported func not being found (Wasmer 1.0.0)
When running the non-WASI example, the invocation fails due to the import failing.
Steps I took:
- install Wasmer 1.0, macOS BS Intel, move away
.dylibso that the linker picks up the .a (not sure it matters) - checkout this repository (wasmer-c-api)
- fix the include from the rust path to
<wasmer.h>://#include "rust-build/src/wasmer-runtime-c-api/lib/runtime-c-api/wasmer.h" #include <wasmer.h> - compile using:
cc -I$HOME/.wasmer/include -L$HOME/.wasmer/lib wasmer-c-api-example.c -o test-simple -lwasmer - run
test-simple
zMBP20:wasmer-c-api helge$ cc -I$HOME/.wasmer/include -L$HOME/.wasmer/lib wasmer-c-api-example.c -o test-simple -lwasmer
zMBP20:wasmer-c-api helge$ ./test-simple
Compile result: 2
Error len: `125`
Error str: `Error while importing "env"."print_str": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })`
Assertion failed: (compile_result == WASMER_OK), function main, file wasmer-c-api-example.c, line 110.
Abort trap: 6
Thanks for the ping: this repo is pretty out of date so a lot of things may not work right... I tried to reproduce and I found that on x86_64 macos it worked with libwasmer.a but not with libwasmer.dylib
clang -I$HOME/.wasmer/include -L$HOME/.wasmer/lib wasmer-c-api-example.c -o test-simple -lwasmer
➜ wasmer-c-api git:(master) ✗ ./test-simple
Compile result: 1
Hello, World!
Call result: 1
I'm not sure why it wasn't working with the dylib:
./test-simple
dyld: Library not loaded: @rpath/libwasmer.dylib
Referenced from: /Users/mark/temp/wasmer-c-api/./test-simple
Reason: image not found
[1] 69683 abort ./test-simple
I'm not using the dylib. The steps I mentioned repro for me all the time.
(Presumably it doesn't work for you because you don't have ~/.wasmer/lib in your DYLIB path.)