Qt 6.9.3 for FBReader on Windows — source, build, and replacement instructions

WHAT WAS BUILT

The isolated SDK is a copy of the official Qt 6.9.3 MSVC2022 shared-library
kit. Release Qt6Multimedia.dll (and its import library) and the SAPI speech
plugin were rebuilt with RelWithDebInfo and the patches listed below. Other Qt DLLs, plugins and
FFmpeg DLLs remain the matching official binaries. This is NOT a rebuild of
all Qt modules. Debug Qt DLLs in the SDK remain upstream and are not release
artifacts. The SAPI word-notification fix is already in upstream Qt 6.9.3.

The backport moves requestStop() before the shutdown-policy switch in
src/multimedia/windows/qwindowsaudiosink.cpp. patches/wasapi-upstream.patch
retains the original authorship and commit. The adapted patch preserves the
6.9.3 worker-thread implementation. Modification date: 2026-11-11.

The local fix in patches/audio-shutdown.patch disconnects and detaches the
input when a WASAPI sink stops, rejects queued pulls after shutdown, and
ties input callbacks to the stream's lifetime. It also disconnects callbacks
on stream destruction. This is FBReader's own fix, not an upstream backport.
Modification date: 2026-11-14. Apply it after wasapi-stop.patch.

The local fix in patches/sapi-initialization.patch rejects a SAPI backend when
COM initialization or native voice creation fails, before Qt can restore
properties through a null voice pointer. It only uninitializes COM after a
successful initialization, including S_FALSE. This is an FBReader modification.
Modification date: 2026-11-16. Apply it to qtspeech, separately from Multimedia.

SOURCES

The app's licenses/qt directory includes this recipe, the modification patches,
and sources.json with exact source versions, public download URLs and SHA256
checksums. Library source archives are not included in the app package.
Copy licenses/qt to a writable directory, then download and verify the sources:

  python fetch-sources.py sources

To verify previously downloaded archives without network access:

  python fetch-sources.py sources --offline

The downloaded Qt module archives include their bundled third-party sources.
The manifest also lists FFmpeg 7.1.1, zlib 1.3.1, the Qt 6.9.3 top-level
repository containing coin/provisioning build scripts, and Vulkan-Headers
1.3.296 for the Vulkan-enabled Qt GUI headers. Mesa 11.2.2 and LLVM 3.6.2
sources are listed for the unchanged x64 software OpenGL fallback. Its
original binary download is recorded in qt5 coin/provisioning/common/windows/
mesa_llvmpipe.ps1. License notices remain included in the package.

Source archives are retained separately with FBReader's release records.
If a listed upstream URL becomes unavailable, contact FBReader support for
the matching archived source; verify its checksum before building.

REBUILD THE PATCHED LIBRARIES

Install Visual Studio 2022 C++ tools, Windows 10/11 SDK, CMake, Ninja, Git,
and Python 3. Include the ATL components for each target architecture
(Microsoft.VisualStudio.Component.VC.ATL and .VC.ATL.ARM64); the Windows SDK's
SAPI helpers require them. Install the official open-source Qt 6.9.3 kit and the modules
qt5compat, qtmultimedia, qtspeech, qtimageformats and qtshadertools. The
x64 kit is win64_msvc2022_64; ARM64 is win64_msvc2022_arm64_cross_compiled.
The ARM64 kit also requires the x64 kit's host tools. aqtinstall can install
these public packages; a commercial Qt license is not required.

From a writable copy of this recipe, on the original ARM64 build host:

  powershell -ExecutionPolicy Bypass -File build.ps1 -Arch x64 -Sources .\sources
  powershell -ExecutionPolicy Bypass -File build.ps1 -Arch arm64 -Sources .\sources

On an x64 development machine, set -VcVars to the installed vcvars64.bat
for x64, or vcvarsamd64_arm64.bat for ARM64. -BaseQt sets the parent of the
msvc2022_64 and msvc2022_arm64 directories. -Work selects a NEW isolated
build root, default C:\fbreader-qt693-wasapi. Set CMake/Ninja/Git/Python in
PATH if installed outside the defaults; the script prepends the original
host's tool locations. Use local Windows disks for build directories.

The script verifies source checksums, extracts and applies the module's patches,
copies the SDK, builds Multimedia and QTextToSpeechSapiPlugin, and replaces
Qt6Multimedia.dll, its import library, and plugins/texttospeech/qtexttospeech_sapi.dll
in that copied SDK. It preserves the original kit and Qt6TextToSpeech.dll.
FFmpeg plugin compilation and spatial-audio compilation are disabled because
neither target is rebuilt; their original binaries are retained. The runtime
default is explicitly kept as FFmpeg. Do not run a full cmake --install from
this partial build, which would replace metadata for targets not built.

Packaged build records include configure arguments, CMake cache, summaries,
compiler version, original kit configuration for this architecture, and binary
hashes. Full SDK SBOMs, logs, export tables and validation results are retained
separately with FBReader's release records. These instructions reproduce
a compatible build, not necessarily byte-identical output. Use a new Work
directory to start over. On subsequent runs the script checks each patch and
applies missing patches to existing source trees; it does not re-extract them.
Locally edited trees must still pass the patch checks. Build records include
patch filenames and SHA256 hashes in patches.json.

RUN THE WINDOWS REGRESSION TESTS (MAINTAINER)

From misc/qt-windows in the FBReader repository, on the Windows build host:

  powershell -ExecutionPolicy Bypass -File test.ps1 -Arch x64
  powershell -ExecutionPolicy Bypass -File test.ps1 -Arch arm64

Use -Work to select a different isolated SDK root. These tests require an
audio output device and installed WinRT/SAPI voices. Results and loaded-DLL
paths are saved under Work\tests-ARCH. audio-shutdown.cpp verifies queued
notifications during playback, no input access after stop/reset/destruction,
restarting with a new input, and push-mode playback. Inputs remain alive so
unwanted reads can be detected with counters. The existing tests also check
worker-thread cleanup and repeated WinRT/SAPI speech operations.

Use -InitializationOnly to run just the SAPI initialization regressions.
sapi-initialization.cpp uses the actual plugin and an existing MTA apartment
to exercise failed initialization, engine switching, getters/cancellation and
recovery in STA without playing audio. sapi-create-failure.cpp compiles the
patched backend/factory with native voice creation failing in the test only;
it checks rejection, error reporting, and COM balance with and without a
caller-owned STA apartment. No fault-injection hook is shipped in the plugin.
Normal SAPI recovery checks require an installed voice; these tests do not
depend on audible playback. SAPI build records are under records-ARCH/sapi.

REBUILD OTHER QT LIBRARIES OR FFMPEG

All unchanged components are also replaceable. Extract the desired source
archives. For an independent Qt SDK, configure qtbase first from an empty
build directory using its configure.bat, e.g.:

  C:\src\qtbase-everywhere-src-6.9.3\configure.bat -opensource -confirm-license -shared -release -force-debug-info -nomake examples -nomake tests -prefix C:\qt-rebuilt
  cmake --build . --parallel 3
  cmake --install .

Use an MSVC environment for the same target architecture as the app. For
ARM64 cross compilation also supply -qt-host-path pointing to an x64 Qt 6.9.3
installation and the target toolchain. Original kit config_*.opt and
config_*.summary in upstream-records document the original feature choices;
CI-specific paths, sccache and SBOM validation tools can be adjusted/omitted.

Configure additional modules with C:\qt-rebuilt\bin\qt-configure-module.bat
C:\src\MODULE, then cmake --build . and cmake --install . in a separate build
directory per module. Dependency order: qtshadertools, qtsvg, qtdeclarative,
qtimageformats, qt5compat, qtmultimedia, qtspeech, qttools, qttranslations.
Use -DQT_BUILD_TESTS=OFF and -DQT_BUILD_EXAMPLES=OFF as appropriate. Apply the
included patches to qtmultimedia and qtspeech as described above. A complete Multimedia rebuild
needs FFmpeg headers/import libraries; pass -- -DFFMPEG_DIR=C:\ffmpeg-rebuilt
and -DQT_DEPLOY_FFMPEG=TRUE. Preserve FFmpeg as the default media backend.

FFmpeg's exact reported build options and license are in upstream-records/
ffmpeg.json. The source archive qt5-6.9.3.tar.gz includes the upstream recipes:
  coin/provisioning/common/windows/install-ffmpeg.ps1
  coin/provisioning/common/windows/zlib.ps1
  coin/provisioning/common/shared/ffmpeg_config_options.txt
and their helper scripts. The zlib recipe documents its two build-time source
adjustments (ARM64 image base and unistd include). Build zlib 1.3.1 with MSVC;
build FFmpeg n7.1.1 with MSYS2 bash/make and MSVC, using the recorded options,
--enable-shared --disable-static and --toolchain=msvc. Set the zlib include
and library paths for your installation. For ARM64 use --arch=arm64
--disable-asm, and --enable-cross-compile when building from x64. Rename
lib*.a import libraries to *.lib as the upstream recipe does. Do not enable
GPL or nonfree options if distributing under the supplied LGPL notices.

REPLACE LIBRARIES WITHOUT REBUILDING FBREADER

1. Close FBReader. Copy the portable FBReader folder to a writable directory.
2. Replace Qt6Multimedia.dll beside FBReader.exe with the DLL from the matching
   architecture's copied SDK bin directory, and texttospeech/qtexttospeech_sapi.dll
   with the plugin from that SDK's plugins/texttospeech directory. Keep the
   other 6.9.3 libraries and plugins. Never mix x64 and ARM64 binaries.
3. For broader changes, copy the compatible Qt6*.dll files and matching
   plugin subdirectories from your rebuilt SDK. Copy rebuilt FFmpeg DLLs
   alongside the executable if changed. Preserve qt.conf and app resources.
4. Run FBReader.exe directly. No FBReader signing key is required. Changing
   DLLs does not require changing the application's executable signature.

An MSIX installation is protected by Windows package signing. Use an editable
copy of its application directory (VFS/ProgramFilesX64/FBReader.ORG Limited/
FBReader in the MSIX archive), or the equivalent standalone portable release,
and follow the above procedure. Do not modify WindowsApps in place. Some
Store-specific services may require package identity; the standalone build
provides the replacement route. A distributor must provide this usable route
alongside the Store version and ensure Store terms do not restrict LGPL rights.
The publisher's signing key is not needed for a portable modified copy.

The supplied runtime test results describe the actual tested environment.
They verify the thread-leak fix and rejection of queued reads after shutdown.
They do not establish that every reported access violation has the same cause,
or that all Windows versions, audio devices and Store installation paths have
been validated.

PREPARE DISTRIBUTION MATERIALS (MAINTAINER)

The maintainer scripts are in the FBReader repository's misc/qt-windows
directory; they are not needed to rebuild or replace the libraries. From that
directory, with the verified archives in WORK/sources and original SDK records
in WORK/upstream-records, run on the packaging host (Python 3.11+):

  python package-materials.py WORK

Then in Windows:

  powershell -File install-materials.ps1 -Materials WORK\materials
  powershell -File package-runtime.ps1 -AppExecutable C:\path\to\FBReader.exe

The last command accepts an x64 FBReader executable as the deployment
dependency input and prepares both architecture runtime ZIPs from the matching
SDKs. These ZIPs do not include FBReader.exe or the Microsoft C++ runtime; use
the application's normal deploy step for those. Run deploy-materials.ps1
after deployment to verify Qt DLLs and attach the distribution materials. Use windeployqt
--no-patchqt so the recorded QtCore hash remains stable. Test the final app
package with a Windows-only PATH, without an SDK on PATH.
