我有一个 CMake 项目 (C++),我想通过 WebAssembly 在 JavaScript 中使用它。为了配置它,我使用emcmake cmake和 来构建它emmake make。当我手动执行此操作时,我可以成功编译部分:
emcc --bind test.cpp
Run Code Online (Sandbox Code Playgroud)
但我想从 的优势中获利emmake。--bind我需要的参数emcc。emmake默认情况下不添加它,这会导致错误:
error: undefined symbol: _embind_register_function (referenced by top-level compiled C/C++ code)
Run Code Online (Sandbox Code Playgroud)
那么,在使用 构建时如何添加它emmake make?我可以将它传递给吗emmake?或者我可以添加一些东西到我的CMakeLists.txt吗?
麦克雷:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(MyTest)
add_executable(mytest test.cpp)
Run Code Online (Sandbox Code Playgroud)
test.cpp:
cmake_minimum_required(VERSION 2.8)
project(MyTest)
add_executable(mytest test.cpp)
Run Code Online (Sandbox Code Playgroud) 我在玩 emscripten 并且不断收到这个令人困惑的消息
|[413077]-$>../emmake Makefile
Error: Exception thrown when invoking Popen in make with args: "Makefile"!
Traceback (most recent call last):
File "../emmake", line 24, in <module>
shared.Building.make(sys.argv[1:])
File "/Users/jkirchartz/Dropbox/emscripten/tools/shared.py", line 670, in make
Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Run Code Online (Sandbox Code Playgroud)
但即使我使用sudo我也会得到同样的错误:
|[254829]-$>sudo !!
sudo ../emmake Makefile
Password:
Error: Exception thrown when invoking Popen in make with args: "Makefile"!
Traceback …Run Code Online (Sandbox Code Playgroud) 在本教程中,它展示了以下导出 C 函数的示例
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
Run Code Online (Sandbox Code Playgroud)
我想做同样的事情,除了我像这样使用 CMake
cd bin
emcmake cmake ../src
emmake make
Run Code Online (Sandbox Code Playgroud)
emmake 中指定的规范方式是什么-s?我应该添加它来CMakeLists.txt喜欢吗
set(EXPORTED_FUNCTIONS '["_int_sqrt"]')
Run Code Online (Sandbox Code Playgroud)
或者做类似的事情?