如何在 Windows 上构建 Ammo.js?

How to build Ammo.js on Windows?

我目前正在尝试按照 README 中的说明在 Windows 上构建 Ammo.js。 我有

显然,因为我在 Windows,cmake 无法解析 CMakeLists.txt

中可执行文件的任何路径
set(EMSCRIPTEN_ROOT $ENV{EMSDK}/upstream/emscripten CACHE STRING "Emscripten path")

所以我不得不用我的二进制文件的完整路径替换它们:

set(EMSCRIPTEN_ROOT "C:/Program Files/emsdk/upstream/emscripten" CACHE STRING "Emscripten path")
set(CMAKE_TOOLCHAIN_FILE "C:/Program Files/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake")
set(WEBIDL_BINDER_SCRIPT "C:/Program Files/emsdk/upstream/emscripten/tools/webidl_binder.py")

现在,如果我 运行 cmake -B builds,cmake 似乎 运行 没有错误,但它吐出以下文件:

cmake -B builds 
-- Building for: Visual Studio 16 2019
-- Found Python3: C:/Python39/python.exe (found version "3.9.1") found components: 
 Interpreter CMake Deprecation Warning at bullet/CMakeLists.txt:1 (cmake_minimum_required): 
 Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
 Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. 
 
 OPENGL FOUND
 
 nul 
 
 -- WARNING: you are using the obsolete 'GLU' package, please use 'OpenGL' instead 
 -- Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OPENGL_INCLUDE_DIR) 
 -- Configuring done 
 -- Generating done
 -- Build files have been written to: G:/dev/projects/ammo.js/builds 

没有ammo.js,没有ammo.wasm.js,也没有ammo.wasm

当我尝试使用 'MinGW Makefiles' 标志进行编译时,出现错误:

cmake -B builds -G 'MinGW Makefiles'
-- Found Python3: C:/Python39/python.exe (found version "3.9.1") found components: Interpreter 
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

我无法使用预建文件,因为调用 new Ammo.btBoxShape(new Ammo.btVector3()) 抛出 Uncaught (in promise) RuntimeError: memory access out of bounds 根据我的理解,我需要在编译期间分配更大的堆。

那么如何在 Windows 上构建 Ammo.js?

这里有两个不同的问题

  1. Chocolatey 的 MinGw 安装不包括 mingw32-make.exe。我卸载了它,得到了 MinGW-Installer and proceeded as per this answer: CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles"

  2. 实际上我不得不在第一个命令之后 运行 cmake --build builds,我在文档中忽略了这一点