I tried to use fopen
to read an image when using wasi-libc
:
#include <stdio.h>
int main()
{
FILE *f = fopen("test.png", "rb");
printf("file %p\n", f);
fclose(f);
}
Build the code with Clang:
$ clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk/share/wasi-sysroot/ test.c -o test.wasm
$ wasmtime test.wasm
$ file 0
It returned NULL. How can I sove the issue?
Fixed: