Siddhant Sahu
Siddhant Sahu

Reputation: 41

How to compile EnergyPlus to WASM (WebAssembly) with Emscripten?

I wanted to compile EnergyPlus (https://github.com/NREL/EnergyPlus) to a WASM module.

These are steps I followed:

  1. Installed Emscripton on system. emcc --check produces the output
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.37-git
shared:INFO: (Emscripten: Running sanity checks)
  1. Cloned the EnergyPlus from GitHub git clone https://github.com/NREL/EnergyPlus
  2. cd EnergyPlus
  3. mkdir build
  4. cd build
  5. emcmake cmake .. This gave the error
-- 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)

Since the EnergyPlus (https://github.com/NREL/EnergyPlus) project is using Cmake as the build system, I followed the section Integrating with a build system from the official documentation of Emscripton.

If emcmake cmake .. succeeds, I would be able to run emcc [-Ox] project.o -o project.js and this would generate the WASM (WebAssembly) module?

Update: For step 6, instead of using cmake .. -DGLFW_USE_OSMESA=1 -DBUILD_STATIC_ENERGYPLUS_API=1 gets rid of the previous error and instead the error I get now is,

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.

Upvotes: 1

Views: 150

Answers (0)

Related Questions