【问题标题】:fopen failed when using wasi-libc使用 wasi-libc 时 fopen 失败
【发布时间】:2020-02-18 09:02:25
【问题描述】:

我在使用wasi-libc时尝试使用fopen读取图像:

#include <stdio.h>

int main()
{
    FILE *f = fopen("test.png", "rb");
    printf("file %p\n", 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。我该如何解决这个问题?

【问题讨论】:

    标签: clang fopen libc wasi wasmtime


    【解决方案1】:

    固定:

    wasmtime --dir=. test.wasm
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多