Reputation: 85
I am trying to build simple webassembly app that consumes a JS object reference (of type emscripten::val
or emscripten::EM_VAL
).
The code:
#include <emscripten.h>
#include <emscripten/bind.h>
#include <emscripten/val.h>
extern "C"
{
EMSCRIPTEN_KEEPALIVE void Draw(emscripten::val canvas)
{
emscripten::val::global("console").call<void>("log", canvas);
}
}
I have tried to build the project that consists only of the code above using emcc
(installed according to instruction), Emscripten CMake toolchain and Blazor WebAssembly (C#/.NET, instruction). Regardless of the way the C++ code is being attempted to compile to wasm, I see the same multiple errors in the output:
NativeClient_0.o: undefined symbol: _emval_get_global
NativeClient_0.o: undefined symbol: _emval_decref
NativeClient_0.o: undefined symbol: _emval_call_void_method
NativeClient_0.o: undefined symbol: _emval_get_method_caller
NativeClient_0.o: undefined symbol: _emval_incref
There are some related issues on github (1, 2). Apart from that I was unable to find any related info and couldn't get my code compiled. What am I doing wrong?
Upvotes: 0
Views: 263
Reputation: 56
Use --bind
for emcc and em++ compilers and remove -s WASM=1
if using it.
Upvotes: 1