Building dpScreenOCR on Windows with MSYS2.

Contents:

  1 Setting up environment
    1.1 MSYS2
    1.2 Dependencies
    1.3 Pandoc
    1.4 C++/WinRT
  2 Building


1 Setting up environment
========================


1.1 MSYS2
---------

Visit https://www.msys2.org for instructions on how to install and set
up MSYS2.

MSYS2 provides several shells. Pick a MinGW shell depending on whether
you want to build a 32-bit or 64-bit version of the program, e.g.
"MSYS2 MINGW32" or "MSYS2 MINGW64". You will never need the MSYS
shell ("MSYS2 MSYS").


1.2 Dependencies
----------------

You will need the following tools and libraries to build dpScreenOCR:

Required:

  * C++ compiler with C++17 support
  * CMake >= 3.22. A particular version of Qt may require a newer
    version of CMake.
  * Make
  * Qt 5.7 - 6. DPSO_QT_VERSION CMake option.
  * tesseract >= 4.1.0
  * jansson >= 2.7
  * gettext >= 0.21
  * pkg-config (recent MSYS2 uses a compatible pkgconf tool)

Optional:

  * pandoc to generate HTML manual. DPSO_GEN_HTML_MANUAL CMake option.

To install all dependencies except Pandoc, run in a MinGW shell:

    pacman -S --needed \
        make \
        $MINGW_PACKAGE_PREFIX-cmake \
        $MINGW_PACKAGE_PREFIX-gcc \
        $MINGW_PACKAGE_PREFIX-gettext \
        $MINGW_PACKAGE_PREFIX-jansson \
        $MINGW_PACKAGE_PREFIX-pkgconf \
        $MINGW_PACKAGE_PREFIX-qt5-base \
        $MINGW_PACKAGE_PREFIX-qt5-translations \
        $MINGW_PACKAGE_PREFIX-tesseract-data-eng \
        $MINGW_PACKAGE_PREFIX-tesseract-ocr

Note that Tesseact data files don't depend on the architecture, so
there is no need to install "tesseract-data-eng" and other languages
for both i686 and x86_64; when building for x86_64, you can use data
from i686 and vice versa. Alternatively, you can download languages as
described in the user manual. Still, be aware that CMake will try to
copy the English language pack installed for the current architecture.


1.3 Pandoc
----------

MSYS2 does not provide Pandoc, so you have to download it from
https://pandoc.org and make it visible to CMake by extending PATH in a
MinGW shell:

    export PATH="$PATH:path_to_pandoc_dir"


1.4 C++/WinRT
-------------

For MSIX packaging support, you need to turn on the DPSO_ENABLE_MSIX
CMake option and install C++/WinRT header files. This also requires
C++20 support from your compiler.

There are 3 ways to install C++/WinRT:

* The easiest way is to install the $MINGW_PACKAGE_PREFIX-cppwirt
  package in MSYS2.

* Since you will need to install Windows SDK anyway (for command line
  utilities), you can use the C++/WinRT headers shipped with SDK. For
  this, check the "Windows SDK for Desktop <architecture> Apps"
  feature during SDK installation.

* If the headers from Windows SDK don't work with your compiler (which
  is the case for old Windows 10 SDK where C++/WinRT unconditionally
  requires <experimental/coroutine> instead of <coroutine>), you can
  compile the recent cppwinrt.exe tool from:

      https://github.com/microsoft/cppwinrt

  And then generate C++/WinRT headers with:

      cppwinrt.exe -input local

In the last two cases, you need to specify the include path for
C++/WinRT headers with the DPSO_WINRT_INCLUDE_DIR CMake option.


2 Building
==========

You can build dpScreenOCR with the following commands:

    cd path_to_dpscreenocr_source
    mkdir build
    cd build
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
    make

You can configure the build with various CMake options; run
"cmake -LH .." to see them all. Options specific to dpScreenOCR have
the "DPSO_" prefix.
