-
Notifications
You must be signed in to change notification settings - Fork 118
BuildingPHD2OnWindows
This page describes how to set up a build environment from scratch on MS-Windows to compile and run PHD2.
- Install CMake
- Install git
- Get the Visual Studio C++ compiler
- (optional) Install Visual Leak Detector
- Install wxWidgets
- Get the PHD2 source code
- Generate the Visual Studio project files
- Compile and run PHD2
- Install CMake, the cross-platform build system:
- Install git:
- If you do not yet have a version of Visual Studio 2022 then download it from
The free Community Edition is all that is needed.
When you run the installer, select the option "Desktop development with C++"
- (Optional) Download and install Visual Leak Detector (VLD) from
- Download wxWidgets 3.0.5 from
PHD2 requires wxWidgets static libraries, not DLLs, so you need to build them as follows.
Install wxWidgets into <wx install path>, typically C:\wxWidgets-3.0.5.
Convert the wxWidgets solution files to VS 2022 by opening C:\wxWidgets-3.0.5\build\msw\wx_vc12.sln with VS 2022 and let Visual Studio convert the solution; close the solution.
Set a WXWIN environment variable to point to <wx install path>. For example:
WXWIN = C:\wxWidgets-3.0.5
Open a Visual Studio command prompt from within VS 2022 (menu Tools => Command Line => Developer Command Prompt) and run two command line builds, one for release, one for debug:
cd %WXWIN%\build\msw
msbuild wx_vc12.sln /p:configuration=Debug /p:platform=win32 /m:8
msbuild wx_vc12.sln /p:configuration=Release /p:platform=win32 /m:8
Extra Info wxWidgets sources are downloaded as a zip file. You should stick with the 3.0.5 release used in the current PHD2 build. On the wxWidgets site, go to the downloads page and find the correct release. If you don't see it there, go to the home page for wxWidgets and look in the 'News' paragraphs. Once it’s downloaded, extract into a location you want.
Then set the WXWIN environment variable as follows: suppose you’ve installed wxWidgets in a folder c:\dev\CPP_Libs\wxWidgets-3.0.5. Then the environment variable should look like this:
WXWIN = C:\dev\CPP_Libs\wxWidgets-3.0.5
- Get the PHD2 source tree from the GitHub. Our project page is https://github.com/OpenPHDGuiding
git clone https://github.com/OpenPHDGuiding/phd2.git
- Generate the Visual Studio project files
The Visual studio project files are generated by cmake based on the CMake input files, primarily CMakeLists.txt. For more information see CMakeBuildSystem. All the build output (including the project files) goes into a temporary directory. Open a command prompt and cd to the PHD2 source directory and run the following:
mkdir tmp
cd tmp
cmake -A Win32 ..
For convenience, there is a batch file containing those commands in the top-level source directory, so you can just run that to do the same thing:
run_cmake.bat
- Build and run PHD2.
Open the solution phd2.sln in the tmp directory. Build the ALL_BUILD project in the solution using the Debug and Release configurations.
Everything should compile cleanly without warnings or errors.