This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-micro-runtime/samples/wasm-c-api
Wenyong Huang 0db04e0b8f
Fix some compile issues of samples (#690)
Fix compile errors of workloads due to emsdk version upgrade,
enable BUILD_TARGET auto set for some samples,
and call wasm_runtime_init_thread_env() for in thread routine which
was created by pthread_create but not runtime in spawn-thread sample.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-08-06 18:12:21 +08:00
..
src Implement most missing wasm-c-api APIs (#303) (#676) 2021-07-28 21:53:37 +08:00
CMakeLists.txt Fix some compile issues of samples (#690) 2021-08-06 18:12:21 +08:00
README.md Enable multi-module support for wasm-c-api (#426) 2020-10-16 17:43:57 +08:00

WAMR supports wasm-c-api in both interpreter mode and aot mode.

Before staring, we need to download and intall WABT.

$ cd /opt
$ wget https://github.com/WebAssembly/wabt/releases/download/1.0.19/wabt-1.0.19-ubuntu.tar.gz
$ tar -xzf wabt-1.0.19-ubuntu.tar.gz
$ mv wabt-1.0.19 wabt

By default, all samples are compiled and run in "interpreter" mode.

$ mkdir build
$ cd build
$ cmake ..
$ make
$ # it will build a library with c-api supporting.
$ # Also copy *.wasm from ../src/
$ # and generate executable files
$ # now, it is ok to run samples
$ ./hello
$ ...
$ ./global
$ ...
$ ./callback
$ ...

They can be compiled and run in aot mode when some compiling flags are given.

$ mkdir build
$ cd build
$ cmake -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_AOT=1 ..
$ make
$ # it will build a library with c-api supporting.
$ # Also copy *.wasm from ../src/
$ # and transform *.wasm to *.aot
$ # and generate executable files
$ # now, it is ok to run samples
$ ./hello
$ ...
$ ./global
$ ...
$ ./callback
$ ...