WX3.0 migration - nohal/OpenCPN GitHub Wiki

Already merged into the official wiki at opencpn.org, won't be updated anymore

Compiling - Windows

The officially supported Windows build platform for OpenCPN 4.1 beta and later is Microsoft Visual Studio 2013 Express for Windows Desktop. It is still possible to perform the build with older versions of Visual Studio, particularly if you are still running Windows XP, you can not install a Visual Studio version newer than 2010.

Prerequisities

  • Get Visual Studio 2013 Express for Windows Desktop or Visual Studio 2013 Community Edition (with Update 4) from https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx

    • Install Visual Studio - you can disable all the optional features offered to save some space
  • Get Git (http://msysgit.github.io)

    • Install and let it register in the PATH environment variable
    • The defaults for all the installation settings are fine except the following:
      • On the Adjusting your PATH environment, select Run Git from the Windows Command Prompt.
      • On the Choosing CR/LF behavior select Checkout as-is, Commit Unix LF.
        • This is really important, the codebase uses Unix LF line endings and commiting CR/LF makes the commits huge and hides their real content.
      • If your git is already installed, please edit the .git/config in your local working copy of the OpenCPN source tree and set autocrlf = input in the [core] section on top.
  • Get Cmake (http://www.cmake.org)

    • Install and let it register in PATH
  • Get Poedit (http://www.poedit.net)

    • Install
    • On 32bit Windows, add C:\Program Files\Poedit\GettextTools\bin to PATH environment variable. On a 64bit system, the path will be C:\Program Files (x86)\Poedit\GettextTools\bin
      • On Windows XP, right-click My Computer, select Properties...
      • On Windows 7 and later, open Computer, click System Properties, and in the left column click Advanced System Settings.
      • On the Advanced tab, click on Environment Variables button and add the path in which msgfmt.exe resides to the PATH system variable.
  • Get NSIS Unicode 2.46.5 (http://www.scratchpaper.com/)

    • Install

Getting and compiling wxWidgets

  • Get the latest 3.0 release from http://wxwidgets.org/downloads/ (at the time of this writing 3.0.2)
  • Uncompress to your drive (we will assume to C:\wxWidgets-3.0.2)

Compiling from the command line (recommended)

  • Run the Developer Command Prompt for VS2013
  • Go to your wxWidgets build tree cd C:\wxWidgets-3.0.2\build\msw and build both release and debug configurations, compatible with Windows XP
nmake -f makefile.vc BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_
nmake -f makefile.vc BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_

Compiling from Visual Studio IDE

This option is more work and not needed for 99% of people. We really mean the previous sentence, do not use this method if you are not familiar with the working of VisualStudio and C++ development - the problems you might face are absolutely not needed if you just want to get a trace of an OpenCPN crash... You have been warned, but if it was not enough, read on.

  • Open wx_vc12.sln
  • Select all project from the Project Explorer, right-click, select Properties, Select All Configurations from the Configuration: dropdown on top and in Configuration Properties -> Generel set the Platform Toolset to Visual Studio 2013 - Windows XP (v120_xp)
  • In the properties of project core, add GDIPlus.lib into Configuration Properties -> Linker -> Input -> Additional Dependencies for both DLL Unicode Debug and DLL Unicode Release configurations

Building OpenCPN

  • Go to your work directory and get the source by cloning the Git repository (We suggest you read at least the very basics at http://git-scm.com/documentation - really)
git clone https://github.com/OpenCPN/OpenCPN.git
  • In case you want to create the setup package from your Release builds, you must get http://sourceforge.net/projects/opencpnplugins/files/opencpn_packaging_data/OpenCPN_buildwin.7z/download and extract the archive into your toplevel OpenCPN source directory created by the clone operation above. The archive contains some binary files needed to produce the installer. In case you just want to develop/debug OpenCPN, this step is not needed at all.
  • Create the build directory and generate the files needed to build OpenCPN
mkdir C:\work\OpenCPN\build
cd C:\work\OpenCPN\build
cmake -T v120_xp ..

Building from Visual Studio IDE

Open the solution file generated earlier by cmake in your build directory (C:\work\OpenCPN\build\OpenCPN.sln), in the Solution Explorer right-click on the opencpn project and select Set as Startup Project from the context menu. Then you can build, run and debug OpenCPN as any other piece of software.

Building from command line

To build OpenCPN from the command line, stay in your build directory and issue one of the following commands depending on whether you want to perform Debug or Release build.

  • Debug build: cmake --build . --config debug --target package
  • Release build: cmake --build . --config release --target package

Running/Debugging from the build directory without installing

  • If you want to debug and you didn't add the WX DLL path to the PATH environment variable earlier, copy the needed WX DLLs to the build directory (Debug or Release, depending on which version you build). The DLLs can be found in C:\${WXDIR}\lib\vc_dll and you will need:
    • Debug: wxbase28ud_net_vc_custom.dll, wxbase28ud_vc_custom.dll, wxbase28ud_xml_vc_custom.dll, wxmsw28ud_adv_vc_custom.dll, wxmsw28ud_core_vc_custom.dll
    • Release: wxbase28u_net_vc_custom.dll, wxbase28u_vc_custom.dll, wxbase28u_xml_vc_custom.dll, wxmsw28u_adv_vc_custom.dll, wxmsw28u_core_vc_custom.dll
  • Create a folder named uidata
    • in the case of a Debug build in your build directory
    • in the case of a Release build in the build/Release directory
  • Copy the following files from src/bitmaps into it: styles.xml, toolicons_traditional.png, toolicons_journeyman.png, toolicons_journeyman_flat.png
  • Copy the following folders from the data subfolder of the source tree to your build/Debug folder (Debug build) or to the build/Release directory (Release build): gshhs, s57data, tcdata
  • For a Release build you also need to copy the following from builwin/crashrpt to build/Release: CrashRpt1402.dll, CrashSender1402.exe, crashrpt_lang.ini, dbghelp.dll

TODO

  • DONE: Include the wx3 DLLs in the Windows setup package
  • DONE: Redesign the packaging to include the VC DLLs directly
  • DONE: Prepare external package with the packaging dependencies to save space in the source repository
  • Bump the plugin API?
  • Detect plugins using wx2.8 and defer their loading
  • Rebuild ocpn_gltest1.exe with wx3, otherwise we would have to bundle also the wx2.8 DLLs (core, custom and gl)
  • DONE: Rebuild CrashRpt to get rid of the MSVCP10.DLL/MSVCR10.DLL dependencies
  • Migrate to NSIS3?
  • Merge the rest of the relevant build instructions
  • Do we need PDBs for the wxWidgets DLLs?