summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/wasm-c-api/README.md
blob: b23276706118fe52a804b49e1a7bc6ecd88c1780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
WAMR supports *wasm-c-api* in both *interpreter* mode and *aot* mode.

Before staring, we need to download and intall [WABT](https://github.com/WebAssembly/wabt/releases/latest).

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

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


``` shell
$ 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.

``` shell
$ 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
$ ...
```