Skip to content

Commit b7474b3

Browse files
authored
Improve Embedding WAMR guideline (#4263) (#4284)
* Fix CMakeList example by adding -lm * Add bh_read_file inclusion to CMakeList * replace non-existing read_binary_to_buffer() to existing bh_read_file_to_buffer() * add #include initialization Signed-off-by: Krisztian Szilvasi <[email protected]>
1 parent 76caabe commit b7474b3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

doc/embed_wamr.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ set (WAMR_ROOT_DIR path/to/wamr/root)
2222
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
2323
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
2424
25-
target_link_libraries (your_project vmlib)
25+
# include bh_read_file.h
26+
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
27+
28+
add_executable (your_project main.c ${UNCOMMON_SHARED_SOURCE})
29+
30+
target_link_libraries (your_project vmlib -lm)
2631
```
2732
Examples can be found in [CMakeLists.txt of linux platform](../product-mini/platforms/linux/CMakeLists.txt) and [other platforms](../product-mini/platforms). The available features to configure can be found in [Build WAMR vmcore](./build_wamr.md#wamr-vmcore-cmake-building-configurations).
2833

@@ -31,6 +36,10 @@ Developer can also use Makefile to embed WAMR, by defining macros and including
3136
## The runtime initialization
3237

3338
``` C
39+
#include "bh_platform.h"
40+
#include "bh_read_file.h"
41+
#include "wasm_export.h"
42+
3443
char *buffer, error_buf[128];
3544
wasm_module_t module;
3645
wasm_module_inst_t module_inst;
@@ -42,7 +51,7 @@ Developer can also use Makefile to embed WAMR, by defining macros and including
4251
wasm_runtime_init();
4352

4453
/* read WASM file into a memory buffer */
45-
buffer = read_wasm_binary_to_buffer(…, &size);
54+
buffer = bh_read_file_to_buffer(…, &size);
4655

4756
/* add line below if we want to export native functions to WASM app */
4857
wasm_runtime_register_natives(...);

0 commit comments

Comments
 (0)