-
Notifications
You must be signed in to change notification settings - Fork 17
Build Windows
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.
-
Download and install Visual Studio Community 2019.
-
Download and build wxWidgets 3.1.1.
-
Download and install CMake 3.16.
-
Clone SolarPILOT repositories.
-
Set environment variables.
-
Run CMake to generate SolarPILOT VS 2019 project files.
-
Build SolarPILOT.
-
Test the build.
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.
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/.
-
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
. -
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 thevc15
file. -
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
SolarPILOT uses CMake to automatically generate build files for Windows, Linux, and Mac.
- 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.
The repositories required to build SolarPILOT are LK, WEX, SSC, SolTrace, and SolarPILOT:
- https://github.com/nrel/lk
- https://github.com/nrel/wex
- https://github.com/nrel/soltrace
- https://github.com/mjwagner2/ssc
- https://github.com/nrel/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.
-
Create a parent folder to store the repositories, for example
...\solarpilot_dev
. -
Clone each repository into the parent folder.
-
Rename the 'ssc' folder to 'ssc-solarpilot'.
...\solarpilot_dev\lk ...\solarpilot_dev\wex ...\solarpilot_dev\ssc-solarpilot ...\solarpilot_dev\soltrace ...\solarpilot_dev\solarpilot
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.
-
Close any open Command windows and Visual Studio if it is running.
-
Open the Windows System Properties window, and on the Advanced tab, click Environment Variables.
-
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 -
Close the System Properties window.
Note. This step is only required the first time you build SolarPILOT or if you have added or removed
.cpp
source files from theCMakeLists.txt
file for LK, WEX, SSC, coretrace, or SolarPILOT.
-
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.
-
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
-
Open a command window, and go to the
build-solarpilot
folder you created above. -
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 ..
- (Optional, but recommended): Add an .editorconfig file to the ...\solarpilot_dev folder to ensure your code is formatted consistently with project standards.
-
Start VS 2019 and open the
...\build-solarpilot\solarpilot_ui.sln
solution file. -
On the Build menu, click Batch Build and then Select All.
-
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 examplesolarpilot_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.
After you have built the project, test the build by starting SolarPILOT and generating a field layout.
-
Go to
...\solarpilot_dev\solarpilot\deploy\x64
and runSolarPILOT.exe
. -
After SolarPILOT starts, click the Field Layout tab.
-
Click Generate new layout.