Building GridLAB-D™ from Source

Developing GridLAB-D™ will inevitably require editing source code and rebuilding the software to evaluate the changes. This section walks through the process of building GridLAB-D™ from source. We also include sub-sections on setting up your development environment to enable this build.

Building on ARM-based Macs

GridLAB-D™ functions best when built as a x86-64 (Intel-chip) binary where macOS can use Rosetta 2 to translate the machine code to run on an ARM-based processor. To switch the macOS Terminal into the x86 (Intel chip) architecture, run the following command.

arch -x86_64 zsh

Complete the rest of the build using the instructions below in this x86 shell.

Install Required Packages

The following packages are required to building GridLAB-D™. Each platform has various means of installing these tools and the command to run to install the tools are shown as part of the list below. In some cases the package manager may need to be separately installed - Ubuntu Linux - apt - comes pre-installed - Windows MSYS2 - pacman - comes pre-installed - Windows WSL - apt - comes pre-installed - macOS: homebrew - Installation instructions here

The following packages are required for compiling/running/debugging GridLAB-D™. - Build support tooling, going by various names for each build environemnt - CMAKE tools, including the "ccmake" TUI - gdb for debugging - git for source code management - xerces (option) for XML support

TODO - Update and verify pre-requisite installation command list for each build platform - Ubuntu Linux: apt-get install build-essential - Windows MSYS2: pacman -S --needed base-devel mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc git - Windows WSL: apt-get install build-essential - macOS: brew install cmake xerces-c

Clone Source Code

GridLAB-D™ has the source code hosted on Github; to build from source this code needs to be locally cloned. From the command-line in your build environment in a folder where you want the source code to live run the following command:

  • git clone https://github.com/gridlab-d/gridlab-d.git
  • git checkout --track origin/feature/1478 (or whatever branch you need to work in)
  • git submodule update --init

Configure CMAKE build

CMAKE is the build system of choice for GridLAB-D™ and there are a number of options that are generally set prior to building and installing GridLAB-D™. These options can be set via a (lengthy) list of command line options or can be set in a more persistent manner using a text user interface (TUI) that is run from the command line.

To configure the CMAKE build, do the following from the just cloned GridLAB-D™ source code folder: - mkdir cmake-build - cd cmake-build - ccmake ../

The following options are more popular ones to define: - CMAKE_BUILD_TYPE - options are "DEBUG" and "RELEASE" - CMAKE_INSTALL_PREFIX - location on the filesystem where GridLAB-D™ will be installed - GLD_HELICS_DIR - location on the filesystem where libhelics is installed - GLD_USE_HELICS - compile with HELICS functionality turned on - GLD_ZeroMQ_DIR - location on the filesystem for libzmq; used by HELICS

When all the options are set, press "c" to configure, and "G" when finished to generate the configuration.

Build and Install

Assuming the configuration produces no errors, building GridLAB-D™ and installing it is easy

sudo cmake --build . --target install

Verify Installation

To verify GridLAB-D™ built and installed successfully, you can run the built-in autotests. Assuming you're working with released or unmodified code, all autotests should pass.

  • cd ../
  • gridlabd -T 0 --validate