Building dpScreenOCR on Windows with MSYS2.

Contents:

  1 Setting up environment
    1.1 MSYS2
    1.2 Dependencies
    1.3 Pandoc
  2 Building
  3 Packaging
    3.1 CPack
    3.2 Inno Setup


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 MinGW x86" or "MSYS2 MinGW x64". 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++11 support (or C++17 when using Qt 6)
  * CMake >= 2.8.12. At least 3.16 is recommended for automatic
    copying of DLLs. A particular version of Qt may require a newer
    version of CMake.
  * Make
  * Qt 4-6. DPSO_QT_VERSION CMake option.
  * tesseract
  * dos2unix

Optional:

  * pkg-config to find tesseract (recent MSYS2 uses a compatible
    pkgconf tool). If not installed, or if you have an old Tesseract
    version that comes without a .pc file for pkg-config, CMake will
    try to find Tesseract on its own.

  * libintl >= 0.21. DPSO_ENABLE_NLS CMake option.

  * gettext tools (msgfmt is needed to compile message catalogs).
    DPSO_ENABLE_NLS CMake option.

  * 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 \
        dos2unix \
        make \
        $MINGW_PACKAGE_PREFIX-cmake \
        $MINGW_PACKAGE_PREFIX-gcc \
        $MINGW_PACKAGE_PREFIX-qt5-base \
        $MINGW_PACKAGE_PREFIX-qt5-translations \
        $MINGW_PACKAGE_PREFIX-pkgconf \
        $MINGW_PACKAGE_PREFIX-tesseract-ocr \
        $MINGW_PACKAGE_PREFIX-tesseract-data-eng \
        $MINGW_PACKAGE_PREFIX-libintl \
        $MINGW_PACKAGE_PREFIX-gettext

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"


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.

DLLs are copied automatically if CMake version is 3.16 or newer. With
older CMake, you have to copy them manually from "$MINGW_PREFIX/bin/".


3 Packaging
===========


3.1 CPack
---------

To create packages, run "cpack -G <generators>", where <generators>
is a semicolon-separated list of generator names you can find in
"cpack --help".

The WIX generator creates an MSI installer. Download WIX from
https://wixtoolset.org/ and tell CPack the path to its binaries either
with CPACK_WIX_ROOT CPack variable (cpack -D CPACK_WIX_ROOT="...") or
with the WIX environment variable (export WIX="...").

The NSIS and NSIS64 generators are no longer supported. Use Inno Setup
instead.


3.2 Inno Setup
--------------

There is inno_setup.iss in the build directory to create an installer
with Inno Setup.

Unless you disable the DPSO_ENABLE_NLS option, you will need some
unofficial language files listed in inno_setup_languages.isi. Download
them from the Inno Setup website or source code repository
(Files/Languages/Unofficial/) to the "Languages/Unofficial/" directory
in the root of your Inno Setup installation.
