The application is written in C++ using the Qt framework. Building is possible
using qmake or cmake. Additionally, scripts are provided for packaging
the application into DEB, RPM packages, or a Windows installer.
- Dependencies and tools
- Getting sources
- Manual building
- Creating the packages and the installers
- CMake options
- Qmake options
- Known issues
- C++11 compiler which is supported by the Qt SDK.
- Qt tools such as
mocand the resource packer. CMakeorQmaketo generate the build scripts.Note that if you're building with
Qmake, you don't need to install theCMakeutils.- SDK for
Qt5orQt6. Minimum supported version is 5.5.Note that with
Qt6you need an additionalCore5Compatmodule. - The CHMLib library for handling chm files. You can choose dynamic or static
linking. In the first case, you need a library and headers for development.
In the second case you need to download the repository submodule and specify
USE_STATIC_CHMLIBflag when generating the build script. - The libzip library and headers for software development. When building this library from source you will need the zlib library.
Note that building using scripts in the
packagefolder may require additional packages; see the "Creating the packages and the installers" section for details.
- I recommend using Git to retrieve the source code. Although you can download and unpack the archive with the sources, this option is not covered here. Also, Git is more convenient if you want to use a submodule with CHMLib.
- GNU Gettext is required to translate the user interface.
In GNU/Linux with package DEB-based manager you need the following packages and their dependencies:
build-essentialcmakegit- One of the following packages, depending on the required Qt and HTML engine:
libqt5webkit5-devqtwebengine5-devqml6-module-qtwebengine,qml6-module-qtwebengine-controlsdelegates,qt6-webengine-devandqt6-5compat-dev
libzip-devlibchm-devgettext
Note that the Ubuntu 22.04 (Jammy) distro does not have the
qt6-5compat-devlibrary and you need to uselibqt6core5compat6-devinstead.
Note that starting with Ubuntu 25.04 (Plucky Puffin) and Debian 13 (Trixie), the
libqt5webkit5-devpackage is no longer available.
Packages for Qt5 and WebKit:
apt install build-essential cmake git gettext \
libzip-dev libchm-dev \
libqt5webkit5-dev
Packages for Qt5 and WebEngine:
apt install build-essential cmake git gettext \
libzip-dev libchm-dev \
qtwebengine5-dev
Packages for Qt6:
apt install build-essential cmake git gettext \
libzip-dev libchm-dev \
qml6-module-qtwebengine qml6-module-qtwebengine-controlsdelegates \
qt6-webengine-dev qt6-5compat-dev
In RedHat-based distributions you need the following packages and their dependencies:
coreutilsgccmakecmakegit- One of the following packages, depending on the required Qt and HTML engine:
qt5-qtwebkit-develqt5-qtwebengine-develqt6-qtwebengine-develandqt6-qt5compat-devel
libzip-develchmlib-develgettext
Packages for Qt5 and WebKit:
dnf install coreutils gcc make cmake git gettext \
libzip-devel chmlib-devel \
qt5-qtwebkit-devel
Packages for Qt5 and WebEngine:
dnf install coreutils gcc make cmake git gettext \
libzip-devel chmlib-devel \
qt5-qtwebengine-devel
Packages for Qt6:
dnf install coreutils gcc make cmake git gettext \
libzip-devel chmlib-devel \
qt6-qtwebengine-devel qt6-qt5compat-devel
In OpenSuse distributions you need the following packages and their dependencies:
coreutilsgccmakecmakegitqt6-base-develqt6-webenginewidgets-develandqt6-qt5compat-devellibzip-develchmlib-develgettext
Install the following packages:
make<prefix>gcc<prefix>gettext-runtime<prefix>gettext-tools<prefix>qt5-base<prefix>qtwebkit<prefix>libzip
Packages for x86_64:
pacman -Syu
pacman -S git make mingw-w64-x86_64-gcc \
mingw-w64-x86_64-gettext-runtime mingw-w64-x86_64-gettext-tools \
mingw-w64-x86_64-qt5-base mingw-w64-x86_64-qtwebkit \
mingw-w64-x86_64-libzip
Or using pacboy:
pacman -Syu
pacman -S pactoys
pacboy -S git: make: gcc:p gettext-runtime:p gettext-tools:p \
qt5-base:p qtwebkit:p libzip:p
Use the git clone command to retrieve the sources. If you need static linking
to CHMLib, use --recursive options to download the CHMLib submodule.
git clone --recursive https://github.com/eBookProjects/uChmViewer
Next, navigate to the folder source files, and create a build folder.
mkdir uChmViewer/build
cd uChmViewer/build
Now you're ready to build the application.
Note that on Fedora and MSYS2, to select Qt5, you need to type
qmake-qt5instead ofqmake.
Build with Qt5 and WebKit using CMake
cmake -DCMAKE_BUILD_TYPE=Release ../
cmake --build . --config Release
Build with Qt5 and WebKit using Qmake
qmake -recursive CONFIG+=release USE_GETTEXT=1 ../
make
make i18n
Build with Qt5 and WebEngine using CMake
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_WEBENGINE=ON ../
cmake --build . --config Release
Build with Qt5 and WebEngine using Qmake
qmake -recursive CONFIG+=release USE_GETTEXT=1 USE_WEBENGINE=1 ../
make
make i18n
Build with Qt6 and WebEngine using CMake
cmake -DCMAKE_BUILD_TYPE=Release -DAPP_QT_VERSION=6 -DUSE_WEBENGINE=ON ../
cmake --build . --config Release
Build with Qt6 and WebEngine using Qmake
qmake6 -recursive CONFIG+=release USE_GETTEXT=1 USE_WEBENGINE=1 ../
make
make i18n
The following scripts are provided for packaging the application:
package/build-deb.shpackage/build-rpm.shpackage/build-win-msys2.sh
These scripts do not install any packages and do not require administrator
privileges. The scripts create a build folder in the current directory and
then build the application in it. After building, the package is copied to the
current directory. The scripts can accept options, a full description of which
is available with the -h switch. There are two commonly used options:
-q <qmake>- specifies the name or full path of theqmakeutility that the script should use.-w <browser>- specifies the HTML engine to use. Possible values:WebEngineorWebKit(default).
Creating a package using the Qt5 and the WebKit
package/build-deb.sh
Creating a package using the Qt5 and the WebEngine
package/build-deb.sh -w webengine
Creating a package using the Qt6 and the WebEngine
package/build-deb.sh -q qmake6 -w webengine
Install additional package.
dnf install rpm-build
Creating a package using the Qt5 and the WebKit
package/build-rpm.sh -q qmake-qt5
Creating a package using the Qt5 and the WebEngine
package/build-rpm.sh -q qmake-qt5 -w webengine
Creating a package using the Qt6 and the WebEngine
package/build-rpm.sh -q qmake6 -w webengine
Install additional packages.
pacboy -S zip: nsis:p ntldd:p
Creating an installer and archive with a portable version using the Qt5 and the WebKit
package/build-win-msys2.sh -q qmake-qt5
CMake comes with a cpack utility for generating installers. The build scripts
have basic cpack support, but in some cases additional options
and variables may need to be specified.
The generator must be specified in any case.
Creating a deb package
cmake -DCMAKE_BUILD_TYPE=Release ../
cmake --build . --config Release
cpack -G DEB -DCPACK_DEBIAN_PACKAGE_SHLIBDEPS=ON
-
-G- specifies a build system generator. This option is not necessary when using the default toolkit. -
--install-prefix <prefix>- specifies a root folder for install application. By defaults to/usr/localon UNIX andc:/Program Files/uchmvieweron Windows. Note, that the installation prefix can be overridden when CMake is run in installation mode (cmake --install) with the--prefixoption. Cpack ignores the installation prefix. -
-D <var>=<value>- specifies the initial value of the CMake script variable.Project-specific variables
USE_STATIC_CHMLIB=<ON | OFF>- choosing static linking with CHMLib, default isOFF. For static linking, the library is compiled from source in thelib/CHMLibfolder. This folder can be obtained along with the sources of the application using the commandgit clone --recursive.USE_WEBENGINE=<ON | OFF>- choosing WebEngine instead of WebKit, default isOFF. WebEngine requires Qt version 5.9 or higher.USE_GETTEXT=<ON | OFF>- enabling translation of the application, default isON. If Gettext is not available, this option will be ignored.USE_DEPLOY_RUNTIME=<ON | OFF>- copying runtime dependencies for deployment, default isOFF.USE_MACOS_BUNDLE=<ON | OFF>- install as macOS bundle, default isON.USE_MAC_APP=<ON | OFF>- use derived QApplication, default toONon macOS.USE_DBUS=<ON | OFF>- use D-Bus integration, default toONon Linux.chmlib_ROOT=<path/to/chmlib>- specifies an additional folder to look up the library and headers for CHMLib. Thechm_lib.hfile is expected either in the root folder or theincludefolder. Thechmlibrary must be either in the root folder or in thelibfolder.libzip_ROOT=<path/to/libzip>- specifies an additional folder to look up the library and headers for libzip. Thezip.hfile is expected either in the root folder or theincludefolder. Theziplibrary must be either in the root folder or in thelibfolder.
CMake-specific variables
CMAKE_PREFIX_PATH=<path/to/qt>is the path to the Qt development package if it is simply unpacked or builds without installation.CMAKE_BUILD_TYPE=<Debug | Release | RelWithDebInfo | MinSizeRel>
For example, configure cmake to build which Qt 5.15 and WebEngine
cmake -DCMAKE_PREFIX_PATH=~/Qt/5.15/gcc -DUSE_WEBENGINE=ON ../
The project options for Qmake are the similar to those for CMake.
USE_STATIC_CHMLIB=1if defined, use static CHMLib from git submodule.USE_WEBENGINE=1if defined, use QtWebEngine.USE_GETTEXT=1if defined, themsgfmtcommand will be used to compile translations.CHMLIB_ROOT=<path/to/chmlib>folder to look up the library and headers for CHMLib.LIBZIP_ROOT=<path/to/libzip>folder to look up the library and headers for libzip.
In addition to the listed above packages you should install qt5-default or
specify the full path /usr/lib/i386-linux-gnu/qt5/bin/qmake instead of qmake.
If the build crashes at the linking stage because the GL library is missing
even after installing the libgl-dev package, it may be needed to link
/usr/lib/lib/libGL.so to the regular library:
ln /usr/lib/i386-linux-gnu/libGL.so.1.7.0 /usr/lib/libGL.so
Correct build is only possible under the following conditions:
- Using Qt5.
- Using QtWebKit.
- Using the built-in CHMLib library.
In some cases, it is necessary to explicitly specify the architecture for which the application is being build.
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ../
qmake -r QMAKE_APPLE_DEVICE_ARCHS=arm64 ../
See Qt for macOS
- Debian releases https://www.debian.org/releases/index
- Debian packages https://packages.debian.org
- Ubuntu releases https://documentation.ubuntu.com/project/release-team/list-of-releases
- Ubuntu packages https://packages.ubuntu.com
- Fedora packages https://packages.fedoraproject.org
- MSYS2 packages https://packages.msys2.org