我试图在使用wasi-libc
时使用fopen
来读取图像:
#include <stdio.h>
int main()
{
FILE *f = fopen("test.png", "rb");
printf("file %pn", f);
fclose(f);
}
使用 Clang 构建代码:
$ clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk/share/wasi-sysroot/ test.c -o test.wasm
$ wasmtime test.wasm
$ file 0
它返回 NULL。我该如何解决问题?
已修复:
wasmtime --dir=. test.wasm