OpenCPN Compiling on Windows

官方编译教程

Compiling on Windows :: OpenCPN Developer Manual

Prerequisities

  • 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 SDKcomponent. Generally install the most current version, Windows 10 preferred.

Git

  • Get Git for Windows from https://gitforwindows.org

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

CMake

  • Get the latest CMake installation packages from https://cmake.org

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

POedit

  • Get the latest POedit installation package from https://poedit.net

  • Install

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

NSIS

  • Download NSIS (Nullsoft Scriptabe Install System) from Download - NSIS

  • Install

GNU gettext

  • Download the setup package from GetText for Windows

  • Install

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

7-Zip

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:
bash 复制代码
cd C:\Users\myname\Sources
git clone -b v3.1.2 https://github.com/wxWidgets/wxWidgets
cd wxWidgets
git submodule init
git submodule update

cd build\msw
nmake /f makefile.vc BUILD=release SHARED=1 CXXFLAGS=/D_USING_V141_SDK71_ CFLAGS=/D_USING_V141_SDK71_ LDFLAGS=/SUBSYSTEM:WINDOWS,5.01
nmake /f makefile.vc BUILD=debug SHARED=1 CXXFLAGS=/D_USING_V141_SDK71_ CFLAGS=/D_USING_V141_SDK71_ LDFLAGS=/SUBSYSTEM:WINDOWS,5.01
  • Set the environment variable wxWIDGETS_ROOT_DIR with a value of the top level directory of your wxWidgets source tree.
Alternatives:
  • 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 https:__github.com/wxWidgets/wxWidgets/releases/tag/v3.1.2.

  • Alternatively there is a faster way to get started, by just getting wxWidgets prebuilt from wxWidgets-3.1.2.7z. 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 2017execute the following commands:

bash 复制代码
cd \Users\myname\Sources
git clone https://github.com/OpenCPN/OpenCPN
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.
bash 复制代码
cd C:\Users\myname\Sources\OpenCPN
mkdir build
cd build
cmake -G "Visual Studio 15 2017" -T v141_xp ..

# 注意这一步可以会一直提示找不到wxWidgets, 
# 建议直接把路径加上
# cmake -DwxWidgets_ROOT_DIR=D:/ThirdParty/wxWidgets/wxWidgets-3.1.2  -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.

Alternatives:
  • 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

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 https://github.com/transmitterdan/BatchUTILS to your github directory, next to the OpenCPN local repository. Discussion about https:__github.com/transmitterdan/BatchUTILS/issues/1[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.

NOTE:

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

bash 复制代码
install:
  # 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 https://download.opencpn.org/s/54HsBDLNzRZLL6i/download -FileName nsis-3.04-setup.exe
  - cmd: nsis-3.04-setup.exe /S

  # Download and unzip wxwidgets, version 3.1.2
  - ps: Start-FileDownload https://download.opencpn.org/s/E2p4nLDzeqx4SdX/download -FileName wxWidgets-3.1.2.7z
  - cmd: 7z x wxWidgets-3.1.2.7z -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 makefile.vc BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_
  #- cmd: nmake -f makefile.vc BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_

before_build:
  - cd c:\project\opencpn
  - mkdir build
  - cd build
  - ps: Start-FileDownload https://download.opencpn.org/s/oibxM3kzfzKcSc3/download -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 ..

build_script:
  # - cmake --build . --config debug
  - cmake --build . --target opencpn --config RelWithDebInfo
  - cmake --build . --target package --config RelWithDebInfo
相关推荐
岫珩27 分钟前
“由于启动计算机时出现了页面文件配置问题,Windows在你的计算机上创建了一个临时页面文件。。。”的问题解决
windows
李菠菜1 小时前
解决Windows系统下Git克隆时报错“unable to checkout working tree”的方法详解
windows·git
子非衣5 小时前
Windows云主机远程连接提示“出现了内部错误”
服务器·windows
剁椒排骨7 小时前
win11什么都不动之后一段时间黑屏桌面无法显示,但鼠标仍可移动,得要熄屏之后才能进入的四种解决方法
运维·windows·经验分享·计算机外设·win11·win10
李菠菜7 小时前
Windows Terminal 集成 Git Bash 的简洁配置指南
windows·git
大数据魔法师8 小时前
Hadoop生态圈框架部署 - Windows上部署Hadoop
大数据·hadoop·windows
江沉晚呤时9 小时前
深入了解C# List集合及两种常见排序算法:插入排序与堆排序
windows·sql·算法·oracle·c#·排序算法·mybatis
聂 可 以15 小时前
推荐几个可以免费下载视频的软件(Neat Download Manager、蜗牛下载助手、bilidown)
windows·开源软件
菜鸟射手1 天前
QT creater和vs2017文件路径问题
linux·c++·windows·qt
爱编程的鱼1 天前
Windows 各版本查找计算机 IP 地址指南
人工智能·windows·网络协议·tcp/ip·tensorflow