You need to enable JavaScript to run this app. 如何使用Emscripten将EnergyPlus编译为WASM(WebAssembly)模块?
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Emscripten将EnergyPlus编译为WASM(WebAssembly)模块?

编译EnergyPlus为WASM模块遇到的问题及疑问

环境与前期操作步骤

  • 已安装Emscripten,执行emcc --check验证环境,输出如下:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.37-git
shared:INFO: (Emscripten: Running sanity checks)
  • 克隆EnergyPlus仓库:git clone https://github.com/NREL/EnergyPlus
  • 进入项目目录并创建构建目录:
cd EnergyPlus
mkdir build
cd build

首次构建错误

执行emcmake cmake ..时触发X11依赖缺失错误:

-- Using X11 for window creation
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindX11.cmake:481 (find_package_handle_standard_args)
  third_party/penumbra/vendor/glfw/CMakeLists.txt:196 (find_package)

调整参数后的新错误

修改构建命令为cmake .. -DGLFW_USE_OSMESA=1 -DBUILD_STATIC_ENERGYPLUS_API=1后,X11错误消失,但出现CMake目标导出错误:

CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "energypluslib" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_options" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_fp_options" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_warnings" that is not in any export set.

疑问

参考Emscripten官方文档「Integrating with a build system」章节后,想确认:若emcmake cmake ..执行成功,后续运行emcc [-Ox] project.o -o project.js是否能生成WebAssembly(WASM)模块?


内容的提问来源于stack exchange,提问作者Siddhant Sahu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 10:05:23