weixin_39833763
2020-11-29 19:37 阅读 0

Can I export native static function to wasm module?

Hi, I am wondering if it's possible to export a native static function to wasm module.

该提问来源于开源项目:bytecodealliance/wasm-micro-runtime

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • weixin_39935319 weixin_39935319 2020-11-29 19:37

    Hi, please ref to export native api on how to define and register native API for wasm app and how to call it in wasm app.

    点赞 评论 复制链接分享
  • weixin_39833763 weixin_39833763 2020-11-29 19:37

    Hi, please ref to export native api on how to define and register native API for wasm app and how to call it in wasm app.

    Hi, thanks for your answer. The document only gives an example of some non-static functions. Does wamr export the static function like static int helloworld() in the same way as exporting the non-static ones? Because when I try to export some static native function and add them in the native symbols, the compiler would say undefined reference like this:

    
    arm-zephyr-eabi/bin/ld: app/libapp.a(main.c.obj):(.data.native_symbols.16673+0x54): undefined reference to `helloworld'
    collect2: error: ld returned 1 exit status
    

    When I remove the static, it works normally.

    点赞 评论 复制链接分享
  • weixin_39833763 weixin_39833763 2020-11-29 19:37

    Oops, I closed this issue by accident

    点赞 评论 复制链接分享
  • weixin_39935319 weixin_39935319 2020-11-29 19:37

    It could be static function, see libc buildin wrappers, and libc wasi wrappers, as far as the native function and the native symbol array are defined in the same file. Do you define the static native function and native symbol array in different files?

    点赞 评论 复制链接分享
  • weixin_39833763 weixin_39833763 2020-11-29 19:37

    It could be static function, see libc buildin wrappers, and libc wasi wrappers, as far as the native function and the native symbol array are defined in the same file. Do you define the static native function and native symbol array in different files?

    Yes, I just noticed that my function is not defined in the same file where the native symbol array is created. There is no more error now. Thanks!

    点赞 评论 复制链接分享

相关推荐