Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Non-WASI example fails due to imported func not being found (Wasmer 1.0.0) #17

Open
helje5 opened this issue Jan 9, 2021 · 2 comments

Comments

@helje5
Copy link

helje5 commented Jan 9, 2021

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 .dylib so 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
@MarkMcCaskey
Copy link
Contributor

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

@helje5
Copy link
Author

helje5 commented Jan 12, 2021

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.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants