From aebbe856c0bea3d6756a232808c669725d626073 Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Thu, 10 Sep 2026 09:46:38 +0200 Subject: [PATCH] maybe fixed a windows(slop) version --- .gitignore | 1 + Makefile | 18 ++++++++++++- README.md | 77 ++++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 79 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index da0487f..f57ee59 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ error.txt error.log CLAUDE.md progress/ +dist/ # Object files *.o diff --git a/Makefile b/Makefile index dbb622d..8cdbd5d 100644 --- a/Makefile +++ b/Makefile @@ -38,4 +38,20 @@ clean: run: $(TARGET) ./$(TARGET) -.PHONY: all clean run +# Windows only: copy the executable and every non-system (MinGW/GTK) DLL it +# needs into dist/ so the app can be started by double-clicking, without an +# MSYS2 shell on PATH. +ifeq ($(OS),Windows_NT) +bundle: $(TARGET) + @rm -rf dist + @mkdir -p dist + @cp $(TARGET) dist/ + @ldd $(TARGET) | grep -Ei '/(ucrt64|mingw64)/bin/' | awk '{print $$3}' \ + | xargs -r -I{} cp -f {} dist/ + @echo "Bundled into dist/ - run dist/$(TARGET)" +else +bundle: + @echo "make bundle is only needed on Windows (MSYS2/MinGW)." +endif + +.PHONY: all clean run bundle diff --git a/README.md b/README.md index 4e58f89..e3b466b 100644 --- a/README.md +++ b/README.md @@ -104,16 +104,14 @@ Linux (Arch): sudo pacman -S gtk4 ``` -Windows (MSYS2) – install [MSYS2](https://www.msys2.org/), then open the -**UCRT64** shell (not the plain “MSYS” one) and run: +Windows – GTK 4 has **no native Windows installer**. On Windows it is +distributed through [MSYS2](https://www.msys2.org/), a Unix-like build +environment that comes with its own package manager called **`pacman`**. -```bash -pacman -S mingw-w64-ucrt-x86_64-gtk4 mingw-w64-ucrt-x86_64-toolchain \ - mingw-w64-ucrt-x86_64-pkgconf make -``` - -If you prefer the older MINGW64 environment instead of UCRT64, use the -`mingw-w64-x86_64-…` package names and open the **MINGW64** shell. +`pacman` is **not** a Windows command. It only exists inside an MSYS2 +terminal, so it will not work in `cmd.exe` or PowerShell. Install MSYS2 +first, then follow the [Windows step-by-step](#windows-step-by-step) +instructions below. #### 2. Build tools (compiler, Make, pkg-config) @@ -145,9 +143,10 @@ sudo dnf install pkgconf-pkg-config sudo pacman -S base-devel pkgconf ``` -Windows – the `pacman` command above already installs GCC, Make and -pkgconf inside the UCRT64/MINGW64 environment. Always build and run from -that shell so the MinGW `PATH` (and GTK DLLs) are available. +Windows – the MSYS2 packages installed in the step above already include +GCC, Make and pkgconf; there is nothing extra to install. Always build and +run from the **MSYS2 UCRT64** terminal so the MinGW `PATH` (and the GTK +DLLs) are available. ### Building the Application @@ -185,10 +184,56 @@ or ./maturita.exe ``` -On Windows, run the binary from the UCRT64/MINGW64 shell (or copy the -required GTK DLLs next to `maturita.exe`). Double-clicking the `.exe` -from Explorer usually fails with a missing-DLL error unless those -libraries are on `PATH`. +### Windows step-by-step + +There is no native Windows build of GTK, so the whole toolchain lives +inside MSYS2. From start to finish: + +1. **Install MSYS2** from and complete the + installer (accept the default install location). + +2. Open the **“MSYS2 UCRT64”** entry from the Start menu. This is a + special terminal, **not** Command Prompt or PowerShell – `pacman` only + exists here. (If you run `pacman` in `cmd.exe`/PowerShell you will see + “`'pacman' is not recognized`”, which is expected.) + +3. In that MSYS2 UCRT64 terminal, install the compiler and GTK 4: + + ```bash + pacman -S --needed mingw-w64-ucrt-x86_64-gtk4 \ + mingw-w64-ucrt-x86_64-toolchain \ + mingw-w64-ucrt-x86_64-pkgconf make + ``` + +4. `cd` into this repository (MSYS2 uses `/c/...` for `C:\...`) and build: + + ```bash + cd /c/path/to/maturita.c + make + ``` + + The Makefile detects Windows automatically and produces `maturita.exe`. + +5. Run it from the same terminal: + + ```bash + make run # or: ./maturita.exe + ``` + +#### Running the `.exe` without the MSYS2 shell + +`maturita.exe` needs the GTK/MinGW DLLs next to it (or on `PATH`) to +start, so double-clicking it from Explorer normally fails with a +missing-DLL error. The Makefile can collect the required DLLs into a +`dist/` folder: + +```bash +make bundle +``` + +Then launch `dist/maturita.exe` by double-clicking it or from Explorer. +Running the app from the MSYS2 UCRT64 terminal (step 5) always works and +needs no bundling. ## Usage