Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call a native webassembly file in c/c++ source code? #1130

Closed
darkmoon233 opened this issue Jul 25, 2019 · 5 comments
Closed

How to call a native webassembly file in c/c++ source code? #1130

darkmoon233 opened this issue Jul 25, 2019 · 5 comments

Comments

@darkmoon233
Copy link

In the JavaScript, you can use the WebAssembly.instantiate function to load a WASM file and use the various methods provided by the WASM file. I want to know if there is such a way in C++ that I can use WASM files directly.

@binji
Copy link
Member

binji commented Jul 25, 2019

You'll probably want to look at https://github.com/WebAssembly/wasm-c-api. There has been work making various wasm engines support this API (not much on wabt though).

@darkmoon233
Copy link
Author

What I want to achieve is the cross-call between c++ and wasm. This must depend on the wasm interpreter. I think it may be some help in wabt.

@binji
Copy link
Member

binji commented Jul 29, 2019

Yes, this is possible in wabt, see test-interp.cc for example. But this uses wabt's own internal interface. The wasm-c-api has (what we hope to be) a standard interface for doing this: https://github.com/WebAssembly/wasm-c-api/blob/master/include/wasm.hh#L634-L652

@sbc100
Copy link
Member

sbc100 commented Sep 12, 2019

I created #1158 to request the C-API be implemented here.

@binji
Copy link
Member

binji commented Sep 25, 2019

OK, we can close this issue in favor of that one.

@binji binji closed this as completed Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants