Skip to content

Build Windows

Mike Wagner edited this page Jun 14, 2021 · 10 revisions

These instructions are for setting up your computer to build the Windows version of SolarPILOT from the C++ code repositories. The entire setup process should take between one and two hours. Once your computer is set up, it should take several minutes to build SolarPILOT.

Overall Steps

  1. Download and install Visual Studio Community 2019.

  2. Download and build wxWidgets 3.1.1.

  3. Download and install CMake 3.16.

  4. Clone SolarPILOT repositories.

  5. Set environment variables.

  6. Run CMake to generate SolarPILOT VS 2019 project files.

  7. Build SolarPILOT.

  8. Test the build.

1. Download and Install Visual Studio Community 2019

If you do not have Visual Studio Community 2019 (VS 2019) installed on your computer, download it from https://www.visualstudio.com/downloads/.

Using VS 2019 requires a free Microsoft account, which you will be prompted to create or enter when you first start the program.

Run the installer and select the following three workloads:

  • Desktop development with C++

  • Python development

  • Linux development with C++ (for CMake)

If you have a different version of Visual Studio installed on your computer, you can install and run VS 2019 side-by-side with the other version.

2. Download and Build wxWidgets 3.1.1

SolarPILOT's user interface uses wxWidgets 3.1.1, which is not the latest version. The latest version of wxWidgets may or may not work with SolarPILOT. It is available at https://www.wxwidgets.org/downloads/.

  1. Download the Windows source code either as a ZIP or 7Z file for Version 3.1.1 from https://github.com/wxWidgets/wxWidgets/releases/tag/v3.1.1, and extract the files to a folder, for example c:\wxWidgets-3.1.1.

  2. Start VS 2019 and open the c:\wxWidgets-3.1.1\build\msw\wx_vc15.sln solution file. There are project files for other versions of Visual Studio, so be sure to open the vc15 file.

  3. Build x64 Debug and Release configurations: In the VS 2019 toolbar, choose the configuration and platform, and then either press the F7 key, or choose Build Solution from the Build menu.

If the build fails, you may need to "retarget" the solution by right-clicking the solution name in the Solution Explorer and choosing Retarget solution from the shortcut menu (or from the Project menu) and select version 10.0 for the Windows SDK.

If the builds succeed, you should see a folder for each configuration you built in the c:\wxWidgets-3.1.1\build\msw folder, each containing several folders and a handful of .pch files:

vc_x64_mswu
vc_x64_mswud

3. Download and Install CMake 3.16

SolarPILOT uses CMake to automatically generate build files for Windows, Linux, and Mac.

  1. Download and install CMake 3.16 from https://cmake.org/download/ with the Add CMake to the System Path for … option selected.

When the installation finishes, verify that CMake was added to the Windows system path.

4. Clone SolarPILOT Code Repositories

The repositories required to build SolarPILOT are LK, WEX, SSC, SolTrace, and SolarPILOT:

The latest code is in the develop branch of each repository except for ssc, which uses the solarpilot-develop branch. Make sure you check out the solarpilot-develop branch after cloning ssc. If you are contributing code, you should work from the develop (or solarpilot-develop) branch. To build a specific version of SolarPILOT, you can check out a tag for that version.

  1. Create a parent folder to store the repositories, for example ...\solarpilot_dev.

  2. Clone each repository into the parent folder.

  3. Rename the 'ssc' folder to 'ssc-solarpilot'.

    ...\solarpilot_dev\lk
    ...\solarpilot_dev\wex
    ...\solarpilot_dev\ssc-solarpilot
    ...\solarpilot_dev\soltrace
    ...\solarpilot_dev\solarpilot
    

5. Set Environment Variables

SolarPILOT's build tools use Windows environment variables to determine where the files it needs are stored on your computer.

Note. This step is only required the first time you build SolarPILOT, or if you move or rename repository folders.

  1. Close any open Command windows and Visual Studio if it is running.

  2. Open the Windows System Properties window, and on the Advanced tab, click Environment Variables.

  3. Under the user variables list, click New, and type values for the variable name and value for each item in the table below.

    For example, if you put the LK repository in c:\solarpilot_dev\lk, you would set the environment variable's name to "LKDIR" and its value to "c:\solarpilot_dev\lk" (you do not need to type the quotes).

    LKDIR ...\solarpilot_dev\lk
    WEXDIR ...\solarpilot_dev\wex
    SSCDIR ...\solarpilot_dev\ssc-solarpilot
    CORETRACEDIR ...\solarpilot_dev\soltrace\coretrace
    WXMSW3 ...\wxWidgets-3.1.1
  4. Close the System Properties window.

7. Run CMake to Generate SolarPILOT VS 2019 Project Files

Note. This step is only required the first time you build SolarPILOT or if you have added or removed .cpp source files from the CMakeLists.txt file for LK, WEX, SSC, coretrace, or SolarPILOT.

  1. Use a text editor to create CMakeLists.txt in the SolarPILOT parent folder (...\solarpilot_dev\CMakeLists.txt in our example) with the following contents:

    cmake_minimum_required(VERSION 3.12)
    Project(solarpilot_ui)
    
    add_subdirectory(lk)
    add_subdirectory(wex)
    add_subdirectory(ssc-solarpilot)
    add_subdirectory(soltrace/coretrace)
    add_subdirectory(solarpilot)
    

Note that there can only be one file with the name'CMakelists.txt' in the build directory, so if you have used this directory for another CMake build, you will need to temporarily rename or move the other existing 'CMakelists.txt' file.

  1. Create a folder named build-solarpilot in the SolarPILOT parent folder (...\solarpilot_dev\build-solarpilot). You should now have a directory structure for SolarPILOT that looks like this (for our example, this would be the contents of ...\solarpilot_dev):

    build-solarpilot
    lk
    soltrace
    solarpilot
    ssc-solarpilot
    wex
    CMakeLists.txt
    
  2. Open a command window, and go to the build-solarpilot folder you created above.

  3. Run the following CMake command:

cmake -G "Visual Studio 16 2019" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_SYSTEM_VERSION=10.0 -DSAM_SKIP_TOOLS=1 .. 

When CMake finishes, you should see ...\build-solarpilot\solarpilot_ui.sln file, with supporting files and a folder for each SolarPILOT repository in the build-solarpilot folder.

If you get build errors about missing files, check the environment variables to makes sure they are correctly named and point to the correct folders.

If you are running CMake to generate a new solution file after creating or removing .cpp files from the LK, WEX, SSC, coretrace, or SolarPILOT repositories, go to the ...\solarpilot_dev folder, and use the following commands from a command window or batch (.bat) file to clean up before running CMake:

rmdir /Q/S build-solarpilot
mkdir build-solarpilot
cd build-solarpilot
cmake -G "Visual Studio 16 2019" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_SYSTEM_VERSION=10.0 -Dskip_tools=1 .. 
  1. (Optional, but recommended): Add an .editorconfig file to the ...\solarpilot_dev folder to ensure your code is formatted consistently with project standards.

8. Build SolarPILOT

  1. Start VS 2019 and open the ...\build-solarpilot\solarpilot_ui.sln solution file.

  2. On the Build menu, click Batch Build and then Select All.

  3. Click Build.

Notes

  • The executable files and libraries required to run SolarPILOT are in ...solarpilot_dev\solarpilot\deploy\x64, not in the build folder.

  • The files for LK, WEX, coretrace, and SSC are in the ...solarpilot_dev\build-solarpilot folders for each repository, for example solarpilot_dev\build-solarpilot\lk\Release.

  • LK, WEX, SSC, coretrace, and SolarPILOT each have their own repository in GitHub.com, so changes should be committed to each repository.

9. Test the build

After you have built the project, test the build by starting SolarPILOT and generating a field layout.

  1. Go to ...\solarpilot_dev\solarpilot\deploy\x64 and run SolarPILOT.exe.

  2. After SolarPILOT starts, click the Field Layout tab.

  3. Click Generate new layout.