Skip to content

BuildingPHD2OnWindows

Andy Galasso edited this page May 4, 2018 · 25 revisions

This page describes how to set up a build environment from scratch on MS-Windows to compile and run PHD2.

Summary

  1. Install CMake
  2. Get the Visual Studio C++ compiler
  3. Install Visual Leak Detector (optional)
  4. Install wxWidgets
  5. Install opencv
  6. Get the PHD2 source code
  7. Generate the Visual Studio project files
  8. Compile and run PHD2

Step-by-step

  1. Install CMake, the cross-platform build system:

http://www.cmake.org/download/

We highly recommend installing cmake version 3.5.2 as that is the version used by most developers and the version used on the build server. cmake-3.5.2-win32-x86.msi

  1. If you do not yet have a version of Visual Studio 2013 for Windows Desktop then download it from

http://www.visualstudio.com/en-us/downloads

The download you want is Visual Studio Express 2013 for Windows Desktop or Visual Studio Community 2013.

Visual Studio 2013 requires Windows 7 SP1 or later; it will not install on Windows XP.

Both are free but will require you to register with Microsoft after about a month.

  1. (Optional) Download and install Visual Leak Detector (VLD) from

https://github.com/KindDragon/vld/releases

  1. Download wxWidgets 3.0.2 from

http://sourceforge.net/projects/wxwindows/files/

PHD2 requires wxWidgets static libraries, not DLLs, so you need to build them as follows.

Install wxWidgets into , typically C:\wxWidgets-3.0.2.

Set a WXWIN environment variable to point to . For example:

WXWIN = C:\wxWidgets-3.0.2

Open a Visual Studio command prompt (menu Tools => Visual Studio 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.2 release used in the current PHD2 build. On the wxWidgets site, go to the downloads page, then select ‘releases’ at the upper left to find the earlier release package you need. 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.2. Then the environment variable should look like this:

WXWIN = C:\dev\CPP_Libs\wxWidgets-3.0.2

  1. Download OpenCV 2.4.10 from

http://sourceforge.net/projects/opencvlibrary/files/opencv-win/

Run the self extracting executable, and put the opencv folder in any location you like.

Set an environment variable OPENCV_DIR pointing to the install location. For example, if you installed to C:\opencv-2.4.10 then you would set

OPENCV_DIR = C:\opencv-2.4.10

  1. Get the PHD2 source tree from the GitHub. Our project page is https://github.com/OpenPHDGuiding
  git clone https://github.com/OpenPHDGuiding/phd2.git
  1. 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 -G "Visual Studio 12" -DwxWidgets_PREFIX_DIRECTORY=%WXWIN% -DOpenCVRoot=%OPENCV_DIR% ..

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
  1. Build and run PHD2.

Open the solution phd.sln in the tmp directory. Build the ALL_BUILD project in the solution using the Debug and Release configurations.

You will see some warnings when building the cfitsio library, but those can be safely ignored. Everything else should compile cleanly without warnings or errors.

Clone this wiki locally