我有一个 CMake 项目 (C++),我想通过 WebAssembly 在 JavaScript 中使用它。为了配置它,我使用emcmake cmake并构建它emmake make。当我手动编译时,我可以成功编译部件:
emcc --bind test.cpp
但我想从emmake. 我需要--bind. 默认不添加,导致报错:emccemmake
error: undefined symbol: _embind_register_function (referenced by top-level compiled C/C++ code)
那么,在构建时如何添加它emmake make?我可以传给emmake? 或者我可以添加一些东西到我的CMakeLists.txt?
MCRE:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(MyTest)
add_executable(mytest test.cpp)
test.cpp:
#include "emscripten/bind.h"
using namespace emscripten;
std::string getText()
{
return "Hello there from C++!";
}
EMSCRIPTEN_BINDINGS(my_module) {
function("getText", &getText);
}