I transfer a wasi-wasm to C file via wasm2c
.
wasm2c test.wasm -o test.c
And I got a header file and a source C file. Part of the header file shows here.
/* import: 'wasi_snapshot_preview1' 'args_get' */
u32 w2c_wasi__snapshot__preview1_args_get(struct w2c_wasi__snapshot__preview1*, u32, u32);
/* import: 'wasi_snapshot_preview1' 'args_sizes_get' */
u32 w2c_wasi__snapshot__preview1_args_sizes_get(struct w2c_wasi__snapshot__preview1*, u32, u32);
/* import: 'wasi_snapshot_preview1' 'clock_time_get' */
u32 w2c_wasi__snapshot__preview1_clock_time_get(struct w2c_wasi__snapshot__preview1*, u32, u64, u32);
/* import: 'wasi_snapshot_preview1' 'fd_close' */
u32 w2c_wasi__snapshot__preview1_fd_close(struct w2c_wasi__snapshot__preview1*, u32);
To compile the my own C file with the generated files, it requires implement of wasi_snapshot_preview1_xxx
. Only declaration exists in the header file like above.
If I try to compile them without the definition, the error occurs:
clang main.c test.c wasm-rt-impl.c
/usr/bin/ld: /tmp/test-740d87.o: in function `w2c_test_wasi_clock_time_get':
test.c:(.text+0x15b56c): undefined reference to `w2c_wasi__snapshot__preview1_clock_time_get'
/usr/bin/ld: /tmp/test-740d87.o: in function `w2c_test_wasi_args_sizes_get':
test.c:(.text+0x18a07c): undefined reference to `w2c_wasi__snapshot__preview1_args_sizes_get'
...
How could I get the implement of these interfaces?