externref icon indicating copy to clipboard operation
externref copied to clipboard

Getting error "When linking module: "externref" , function name: "insert""

Open IgorKhomenko opened this issue 1 year ago • 1 comments

I have a rust module defined like this

pub mod funcs {
  pub struct Arena(());

  // use wasmedge_bindgen_macro::*;
  use externref::{externref, Resource};

  // #[wasmedge_bindgen]
  #[no_mangle]
  #[externref]
  pub extern "C" fn call_add(arena: &Resource<Arena>, val1: i32, val2: f32) {

  }
}

and compile it like this cargo build --target wasm32-wasi --releas

Then, I try to use this module in a host app written in C, but when I compile and run it via gcc main.c -lwasmedge && ./a.out, it produces an error:

% gcc main.c -lwasmedge && ./a.out
[2024-02-23 15:10:08.146] [error] instantiation failed: unknown import, Code: 0x62
[2024-02-23 15:10:08.147] [error]     When linking module: "externref" , function name: "insert"
[2024-02-23 15:10:08.147] [error]     At AST node: import description
[2024-02-23 15:10:08.147] [error]     At AST node: import section
[2024-02-23 15:10:08.147] [error]     At AST node: module

Is there any additional things I need to do to make it works?

IgorKhomenko avatar Feb 23 '24 13:02 IgorKhomenko