fopen 在使用 WASI-libc 时失败



我试图在使用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

最新更新