构建 WebAssembly 项目时出现多个错误

问题描述 投票:0回答:1

我正在尝试构建使用 JS 对象引用(类型为

emscripten::val
emscripten::EM_VAL
)的简单 WebAssembly 应用程序。

代码:

#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);
    }
}

我尝试使用

emcc
(根据指令安装)、Emscripten CMake工具链和Blazor WebAssembly(C#/.NET,指令)构建仅包含上述代码的项目。无论尝试将 C++ 代码编译为 wasm 的方式如何,我都会在输出中看到相同的多个错误:

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

github 上有一些相关问题(12)。除此之外,我无法找到任何相关信息,也无法编译我的代码。我做错了什么?

blazor-webassembly webassembly emscripten
1个回答
0
投票

对 emcc 和 em++ 编译器使用

--bind
,如果使用则删除
-s WASM=1

© www.soinside.com 2019 - 2024. All rights reserved.