JavaScriptを使用して.wasmにコンパイルされたC関数を呼び出す簡単な例を試しています。私はemcc counter.c -s WASM=1 -o counter.js
を使用して、それをコンパイル"アサーションが失敗しました:ランタイムの準備が整うのを待つ必要があります" JavaScriptでC関数を呼び出すときのエラー
#include <emscripten.h>
int counter = 100;
EMSCRIPTEN_KEEPALIVE
int count() {
counter += 1;
return counter;
}
:
これはcounter.c
ファイルです。私は取得していますエラーがある
<script type="text/javascript" src="counter.js"></script>
<script type="text/javascript" src="main.js"></script>
:
const count = Module.cwrap('count ', 'number');
console.log(count());
マイindex.html
ファイルは本体のみで両方の.jsファイルをロードし、何もない:
のJavaScriptファイル
マイmain.js
Uncaught abort("Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)") at Error
I tr y をmain.js
に電話してください。 ランタイムの準備が整うのをどうやって待つことができますか?