wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Please provide more detail in embedding documentation

Open itowlson opened this issue 2 years ago • 3 comments

I am looking to embed the micro runtime into a host derived from another program's samples, but am having trouble following the documentation. The sample is very minimal, and its makefile is just to cc three source files and then ld them together into an image.

I did a Linux build of the mini-product and got a .so out, but ld couldn't link that with my . giving an error about the symbols being in a different format. I have tried adding .c files to the sample and to its makefile, but getting them to build is proving absurdly laborious because the existing makefile is so minimal, and the mini-product uses a very different build system (and the generated makefiles are beyond my skills).

Now this may be down to the minimalism of my target - I am trying to embed into a bare image rather than an ELF or PE format, and I don't have a stdlib - but with the current embedding documentation I can't tell if it's that or if I'm missing something! It would be super useful if the embedding docs, as well as showing the APIs to call, provided information and examples of how to build and link the WAMR files outside of the WAMR mini product.

Thanks!

itowlson avatar Sep 09 '21 02:09 itowlson

Hi, since there are so many building systems (e.g. make, cmake, autoconf, scons, gyp, etc), it is really hard to document the building process to cover all these tools.

We use cmake for most of the components, and if you are using cmake, we have provided useful cmake scripts under build-scripts

If you are using Makefile, we also have some platform using Makefile as the building tools, please refer to aos.mk, this file is quite simple, all you need to do is to add the source files and include files into the Makefile

If you encounter any problem, could you please provide more details or attach the building logs here so that we can point out the possible solution?

Thanks!

xujuntwt95329 avatar Sep 10 '21 06:09 xujuntwt95329

If I want to embed it in the golang language to run the wasm file, do I refer to this document? https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/embed_wamr.md Language binding of this library

dosgo avatar Sep 23 '21 04:09 dosgo

@dosgo Yes, you can refer to that documents, and what you need to do is to wrapper those APIs and data structures in go.

Alternatively, you can also use wasm-c-api (refer here) to achieve your goal, the number of wasm-c-api is much more than WAMR's embedding API, but it may provide more flexibility.

xujuntwt95329 avatar Sep 23 '21 07:09 xujuntwt95329