में सी फ़ंक्शन को कॉल करते समय त्रुटि I जावास्क्रिप्ट के साथ .wasm में संकलित एक सी फ़ंक्शन को कॉल करने के लिए एक साधारण उदाहरण का प्रयास कर रहा हूं।"दावा विफल: आपको रनटाइम तैयार होने की प्रतीक्षा करनी है" जावास्क्रिप्ट
यह counter.c
फ़ाइल है:
#include <emscripten.h>
int counter = 100;
EMSCRIPTEN_KEEPALIVE
int count() {
counter += 1;
return counter;
}
मैं इसे emcc counter.c -s WASM=1 -o counter.js
का उपयोग कर संकलित।
मेरे main.js
JavaScript फ़ाइल:
const count = Module.cwrap('count ', 'number');
console.log(count());
मेरे index.html
फ़ाइल केवल शरीर, और कुछ नहीं में भार दोनों .js फ़ाइलों:
<script type="text/javascript" src="counter.js"></script>
<script type="text/javascript" src="main.js"></script>
त्रुटि मैं हो रही है:
Uncaught abort("Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)") at Error
जब मैं tr main.js
में कॉल करने के लिए y। रनटाइम तैयार होने के लिए मैं कैसे इंतजार कर सकता हूं?