Compiling on Windows


  • for OpenCPN v5.0.0

  • with wxWidgets v3.1.2

  • Plugin API starts with API 1.16 (Supports plugins with earlier API but they must be compiled again for OpenCPN v5.0 due to the change in wxWidgets.)

  • Highest chance of success if these steps are followed exactly.

Visual Studio 2017

  • Get Visual Studio Community 2017. Go to this microsoft web page Older Visual Studio and scroll down.

  • Install and select the workload Desktop development with C* and include component *Windows XP support for C.

  • Also include the appropriate Windows x SDK component. Generally install the most current version, Windows 10 preferred.


  • Get Git for Windows from

  • Install and let the installer register git in your PATH and select Checkout as-is, commit Unix-style line endings


  • Get the latest CMake installation packages from

  • Install and let the installer register in the PATH environment variable


  • Get the latest POedit installation package from

  • Install

  • Add C:\Program Files (x86)\Poedit\GettextTools\bin to your PATH


GNU gettext


Get the wxWidgets 3.1.2 sources and built them

  • Open a x86 Native Tools Command Prompt for VS 2017 (In Windows 10 by typing in the search box next to the Windows start button x86 Native…etc) and execute the following commands:

cd C:\Users\myname\Sources
git clone -b v3.1.2
cd wxWidgets
git submodule init
git submodule update

cd build\msw
  • Set the environment variable wxWIDGETS_ROOT_DIR with a value of the top level directory of your wxWidgets source tree.


  • The commands on this page refers to C:\users\myname\Sources as the directory for all sources. Obviously one can use other directories.

  • The commands above download the sources from GitHub and then build the release and the debug version. Instead of using git clone, you can download the wxWidgets sources manually from

  • Alternatively there is a faster way to get started, by just getting wxWidgets prebuilt from wxWidgets- This however is not suitable for serious development or debugging as only release configuration libraries are included.

  • Video: wxWidgets with Visual Studio 2019/2017 Getting Visual Studio setup to use wxWidgets can sometimes be difficult, this video uses the Visual Studio Interface.

Getting and building OpenCPN source

Get the OpenCPN sources

In the open x86 Native Tools Command Prompt for VS 2017 execute the following commands:

cd \Users\myname\Sources
git clone

Get prebuilt Windows dependencies

  • Download the dependencies bundle from OpenCPN_buildwin-4.99a.7z

  • Extract into c:\Users\myname\Sources\OpenCPN\buildwin using 7-Zip

Building OpenCPN

  • In the open x86 Native Tools Command Prompt for VS 2017 execute the following commands to create the build directory, generate the solutions files and build the debug version, the release version and the setup package.

cd C:\Users\myname\Sources\OpenCPN
mkdir build
cd build
cmake -G "Visual Studio 15 2017" -T v141_xp ..
cmake --build .
cmake --build . --config release
cmake --build . --config release --target package
  • These commands should generate an OpenCPN install package in c:\Users\username\Sources\OpenCPN\build\opencpn_5.0.0_setup.exe

  • Excecute this program to install OpenCPN. Choose c:\Program Files (x86)\OpenCPN\ as installation directory to avoid unnecessary issues when installing plugins.


  • Instead of running the last 3 cmake-commands, one could also start Visual Studio, open the generated solutionfile OpenCPN.sln and build from there.

  • Obviously other directories can be used as well, just as multiple opencpn installation. The instructions above are meant for those setting up a new development environment for just OpenCPN 5.0.

Setup Copyfiles.bat - Last step to Debug

Copyfiles.bat is a useful single batch file to copy all the needed files to the various directories. This batch file does not execute any cmake commands.

  • Download here

  • Move the file to <Your OpenCPN source tree> (for example: C:\Compile\Github\Opencpn)

  • Execute copyfiles.bat

  • Start Visual Studio 2017 and the OpenCPN-solution file. (For Example: C:\Compile\Github\Opencpn\build\opencpn.sln)

  • If the Solution Explorer is not visible, open the Solution Explorer (Via the view-menu, or Ctrl+Alt+L)

  • Select the project "Opencpn" from the list, right click and pick "Set as Startup Project"

Now Opencpn should be ready to debug.


BatchUTILS is another alternative that is a more complete set of batch files to assist building OpenCPN. Osetup.bat is intended to be modified by an individual user based on their own system. Git clone to your github directory, next to the OpenCPN local repository. Discussion about[the use and development of BatchUtils]

It’s nearly impossible to guess all the possible wxWidgets versions someone might have on their system. Also, other tools sometimes change paths as new versions are released. So it is expected that each user will customize Osetup.bat. The latest of Transmitter Dan’s batchutils is in git. If you want to use some other environment variable other than WXDIR that is ok. The Cmake tool will accept a number of possible environment names as the root of the wxWidgets toolkit.


FIXME: These are the steps in appveyor, and they are not the same

  # VS2015 and earlier version - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86'
  - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"

  # set environment variables for wxWidgets
  - set WXWIN=C:\wxWidgets-3.1.2
  - set wxWidgets_ROOT_DIR=%WXWIN%
  - set wxWidgets_LIB_DIR=%WXWIN%\lib\vc_dll
  - cmd: SET PATH=%PATH%;%WXWIN%;%wxWidgets_LIB_DIR%;C:\Program Files (x86)\Poedit\Gettexttools\bin;C:\Program Files\Git\bin;c:\cygwin\bin
  - cmd: python3.6m --version

  # install dependencies:
  - choco install poedit
  - choco install git

  # - choco install nsis-3.04 -x86
  - ps: Start-FileDownload -FileName nsis-3.04-setup.exe
  - cmd: nsis-3.04-setup.exe /S

  # Download and unzip wxwidgets, version 3.1.2
  - ps: Start-FileDownload -FileName wxWidgets-
  - cmd: 7z x wxWidgets- -o%WXWIN% > null

  # some debugging information
  # - set   Displays sensitive password!
  # - cmake --help

  # build wxWidgets - Disabled as we provide prebuilt WX to save time
  #- cmd: cd %WXWIN%\build\msw\
  #- cmd: nmake -f BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_
  #- cmd: nmake -f BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_

  - cd c:\project\opencpn
  - mkdir build
  - cd build
  - ps: Start-FileDownload -FileName OpenCPN_buildwin-4.99a.7z
  - cmd: 7z x -y OpenCPN_buildwin-4.99a.7z -oc:\project\opencpn\buildwin
  - cmake -T v141_xp -DOCPN_CI_BUILD=ON ..

  # - cmake --build . --config debug
  - cmake --build . --target opencpn --config RelWithDebInfo
  - cmake --build . --target package --config RelWithDebInfo