few changes for running on windows

This commit is contained in:
Agel committed 2026-03-16 11:29:43 +01:00
1 parent 0fcf303946
commit 97c79c17d3
6 files changed
+119 -110

No files matched your search

+72 -32
View File
@@ -8,7 +8,7 @@ A cross-platform desktop book/document reader built with Qt6/C++. Reimplementati
- **Qt 6.4+** (6.4 minimum for QtPdf; 6.5+ recommended)
- **CMake 3.16+**
- **C++17 compiler** — GCC 10+ or Clang 12+ on Linux; MSVC 2022 on Windows
- **C++17 compiler** — GCC 10+ or Clang 12+ on Linux; MinGW-w64 (GCC) via MSYS2 on Windows
## Installing Dependencies
@@ -38,38 +38,86 @@ cmake --find-package -DNAME=Qt6 -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST
### Windows
**Step 1 — Install Qt 6 manually** via the Qt Online Installer (qt.io/download-open-source):
- Select component: `Qt 6.x → MSVC 2022 64-bit`
- Also select: `Qt PDF`, `Qt SVG` under the same Qt version
All Windows dependencies — Qt 6, MinGW-w64, CMake, Ninja, and all third-party libraries — are installed through **MSYS2**, a Linux-like environment for Windows with a proper package manager (`pacman`). This ensures everything is compiled with the same GCC toolchain with no ABI mismatches.
**Step 2 — Install toolchain and third-party libs** (run in an elevated PowerShell):
**Step 1 — Install Git for Windows**
```powershell
scripts\install-deps-windows.ps1
Download and install from [git-scm.com/download/win](https://git-scm.com/download/win). During setup:
- Select "Git from the command line and also from 3rd-party software" (recommended PATH option)
- Use the default options for everything else
**Step 2 — Install MSYS2**
Download and run the installer from [msys2.org](https://www.msys2.org). Use the default install path (`C:\msys64`).
After installation, open the **MSYS2 MINGW64** shell (search the Start menu for "MSYS2 MINGW64" — use this shell, not MSYS2 MSYS or UCRT64) and update the package database:
```bash
pacman -Syu
```
Installs: VS Build Tools 2022, CMake, Ninja, Git, vcpkg, and third-party libs (QuaZip, uchardet, DjVuLibre, libwpd) via vcpkg.
The shell will likely close itself partway through. Reopen it and run the update again to finish:
**Step 3 — Configure CMake** with your Qt install path:
```powershell
cmake -B build -DCMAKE_PREFIX_PATH="C:\Qt\6.x.x\msvc2022_64" `
-DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake"
```bash
pacman -Syu
```
Replace `6.x.x` with your installed Qt version (e.g. `6.7.2`).
**Step 3 — Install Qt 6 and all dependencies**
In the **MSYS2 MINGW64** shell, navigate to the project folder and run the install script (MSYS2 mounts Windows drives as `/c/`, `/d/` etc.):
```bash
cd /c/path/to/asteria-qt
bash scripts/install-deps-windows.sh
```
Or install manually:
```bash
pacman -S --needed \
mingw-w64-x86_64-gcc \
mingw-w64-x86_64-zlib \
mingw-w64-x86_64-qt6-base \
mingw-w64-x86_64-qt6-declarative \
mingw-w64-x86_64-qt6-tools \
mingw-w64-x86_64-qt6-shadertools \
mingw-w64-x86_64-qt6-svg \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-uchardet \
mingw-w64-x86_64-quazip \
mingw-w64-x86_64-djvulibre \
mingw-w64-x86_64-libwpd
```
Verify the installation:
```bash
qmake6 --version
gcc --version
cmake --version
```
**Step 4 — Clone the repository**
```bash
git clone https://github.com/your-org/asteria-qt.git
cd asteria-qt
```
## Building
All build commands run in the **MSYS2 MINGW64** shell on Windows, or a regular terminal on Linux. No extra CMake flags are needed on Windows — MSYS2 installs everything to a standard prefix that CMake finds automatically.
### Command Line
```bash
# Debug build (Linux — Qt6 found automatically after running install script)
cmake -B build -DCMAKE_BUILD_TYPE=Debug
# Debug build
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
# Release build
cmake -B build-release -DCMAKE_BUILD_TYPE=Release
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-release --parallel
# Run tests
@@ -80,7 +128,7 @@ ctest --test-dir build --output-on-failure
```bash
./build/asteria-qt # Linux
./build/asteria-qt.exe # Windows
./build/asteria-qt.exe # Windows (run from MSYS2 MINGW64 shell)
```
### CLion
@@ -89,27 +137,19 @@ ctest --test-dir build --output-on-failure
2. CLion auto-detects `CMakeLists.txt` and configures
3. Select a CMake profile (Debug/Release) in Settings → Build, Execution, Deployment → CMake
4. Build: `Ctrl+F9` / `⌘F9` | Run: `Shift+F10` / `⌃R`
5. On Windows: set `CMAKE_PREFIX_PATH` to your Qt install path in the CMake profile options field
5. On Windows: set the toolchain to use MSYS2's MinGW (`C:\msys64\mingw64\bin\gcc.exe`) under Settings → Build, Execution, Deployment → Toolchains; leave GDB set to **Bundled** — MSYS2's GDB is newer than CLion supports
### VSCode
1. Install extensions: **C/C++**, **CMake Tools**
2. Open the project root
3. CMake Tools detects `CMakeLists.txt` automatically; select a kit (GCC on Linux, MSVC on Windows)
4. On Windows, add to `.vscode/settings.json`:
```json
{
"cmake.configureArgs": [
"-DCMAKE_PREFIX_PATH=C:\\Qt\\6.x.x\\msvc2022_64",
"-DCMAKE_TOOLCHAIN_FILE=C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
]
}
```
3. CMake Tools detects `CMakeLists.txt` automatically
4. On Windows: when prompted to select a kit, choose the MSYS2 MinGW64 GCC kit (points to `C:\msys64\mingw64\bin\gcc.exe`)
5. Build: `Ctrl+Shift+B` | Run: `F5` (with `launch.json`) or CMake Tools' Run button
### Qt Creator
1. File → Open File or Project → select `CMakeLists.txt`
2. Configure the kit (Qt 6 kit must be registered under Edit → Preferences → Kits)
3. Build: `Ctrl+B` / `⌘B` | Run: `Ctrl+R` / `⌘R`
4. On Windows: ensure the Qt 6 MSVC kit is selected
2. Configure the kit under Edit → Preferences → Kits
3. On Windows: add a kit pointing to MSYS2's Qt (`C:\msys64\mingw64`) and MinGW compiler
4. Build: `Ctrl+B` / `⌘B` | Run: `Ctrl+R` / `⌘R`