Skip to content

Windows build: MinGW fixes, GUI subsystem link, icon, tooling + docs - #448

Closed
nmaas87 wants to merge 8 commits into
csete:masterfrom
nmaas87:windows-build
Closed

nmaas87 wants to merge 8 commits into
csete:masterfrom
nmaas87:windows-build

Conversation

@nmaas87

@nmaas87 nmaas87 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Makes gpredict compile, link, and ship correctly on Windows, and adds
the tooling + docs to produce a standalone zip locally — no CI needed.

Build/link fixes:

  • The WIN32 macro is not a usable platform guard: GCC for MinGW only
    predefines it in GNU dialects (the build uses -std=c11), and
    mingw-w64's curl/curl.h defines it mid-file even in native builds.
    Result: the POSIX branch was taken on Windows (arpa/inet.h etc.),
    and TLE/TRSP fetch silently selected the uncompiled win32_fetch().
    -> all guards now use _WIN32; fetch backend selection moved to an
    explicit HAVE_WIN32_FETCH define (only set by win32/Makefile);
    strcasestr() (glibc-only) replaced by the in-tree
    gpredict_strcasestr().
  • configure: AC_SEARCH_LIBS([htons],[ws2_32]) so rigctld/rotctld
    socket calls link on MinGW.
  • On Windows hosts (mingw/msys/cygwin) the autotools build now links
    with -mwindows (no console window behind the GUI on double-click)
    and embeds the pre-existing win32/gpredict.rc via windres
    (app icon + version info in the PE, --output-format=coff).
  • configure: AC_CONFIG_MACRO_DIRS plural — libtoolize >= 2.4.7
    (Ubuntu 24.04) hard-errors on the bootstrap otherwise.
  • .gitattributes: .sh/.py stay LF so MSYS bash accepts them from a
    Windows checkout.

Packaging + cross-build tooling:

  • tools/cross-package.sh: stages a standalone tree — exe (from
    src/.libs, GUI subsystem), full DLL closure walking from the exe
    and from the dlopen'ed gdk-pixbuf loader DLLs (so the SVG/librsvg
    chain ships), data in the compat.c layout, icons, locales, schemas.
  • tools/msys2-sysroot.py: assembles a Windows dependency sysroot from
    MSYS2 repo packages (pacman DB -> .pkg.tar.zst closure, rewrites
    .pc prefixes) for Linux cross-builds.

Docs (doc/BUILDING-WINDOWS.md): native MSYS2 recipe (sections 1-3),
quirks table (4), Linux cross-build flow (5), win32/Makefile history
(6), step-by-step standalone-zip packaging incl. the cross-package.sh . / stage/... native invocation and PowerShell zipping (7).

Verified locally: native MSYS2 build (gcc 15.2 / gtk3 3.24.51) ->
sh tools/cross-package.sh . / stage/... -> zipped: GUI starts with
no console window, file icon shows, SVG logo loads, maps render,
runs standalone with PATH=C:\Windows\System32. Linux cross-build
(Ubuntu 24.04 mingw-w64 + sysroot script) -> same zip quality.

Warning: Code generated by qwen3.8-flash-next-iq3_s

…asestr

The existing guards used the macro WIN32, which GCC for MinGW only
predefines in GNU dialects, never in the strict ISO mode (-std=c11)
that configure enables. On Windows the code therefore took the POSIX
branch: arpa/inet.h, netdb.h, sys/socket.h were included (fatal),
timegm() was used instead of _mkgmtime, and the gmtime_r() shim plus
the winsock2 initialization were compiled out.

Switch all platform/socket guards to _WIN32, which the compiler
defines on every Windows target regardless of dialect. In
gtk-rig-ctrl.c and gtk-rot-ctrl.c, replace the glibc-only strcasestr()
with the existing portable helper gpredict_strcasestr()
(gpredict-utils.c), which the rest of the code already uses.

Warning: Code generated by qwen3.8-flash-next-iq3_s
WIN32 is not a reliable backend selector: mingw-w64's curl/curl.h
itself defines WIN32 on inclusion, so in a native MSYS2 build (which
links libcurl) the later '#ifdef WIN32' blocks in tle-update.c and
trsp-update.c silently switched to win32_fetch() from win32/, which
the autotools build neither includes nor compiles -> implicit
declaration, link failure.

Make the choice explicit: define HAVE_WIN32_FETCH from win32/Makefile
(the only build that compiles win32-fetch.c and skips libcurl) and
guard the fetch code with it. The autotools build now always uses
libcurl, on every platform.

Warning: Code generated by qwen3.8-flash-next-iq3_s
The rigctld/rotctld TCP clients in gtk-rig-ctrl.c/gtk-rot-ctrl.c call
socket/connect/send/... On Unix these live in libc; on MinGW they are
exported by ws2_32.dll, which was never linked -> undefined __imp_*
references at link time. AC_SEARCH_LIBS finds them in libc on Unix and
adds -lws2_32 only where needed.

Warning: Code generated by qwen3.8-flash-next-iq3_s
Step-by-step prereqs/build/install for MSYS2, the Win32 quirks the
build now handles, and the win32/README pointer.

Warning: Code generated by qwen3.8-flash-next-iq3_s
…runners

Warning: Code generated by qwen3.8-flash-next-iq3_s
…Windows hosts

Double-clicking the built gpredict.exe opened a console window
(PE CUI subsystem) and the file had no icon or version info.
win32/Makefile has always handled both (-mwindows + windres over
win32/gpredict.rc); do the same from the autotools build: on a
Windows host (mingw, msys, cygwin - note that autotools inside
MSYS2 reports the host as *-*-msys) link with -mwindows and compile
win32/gpredict.rc (icon + VERSIONINFO with the numeric VERSION)
with windres when available. The rc/ico/resource.h files themselves
are pre-existing. Quirk table row added to doc/BUILDING-WINDOWS.md.

Warning: Code generated by qwen3.8-flash-next-iq3_s
tools/msys2-sysroot.py assembles a Windows dependency sysroot from
MSYS2 repo packages (pacman DB -> per-package .pkg.tar.zst closure,
rewrites .pc prefixes). tools/cross-package.sh stages exe + DLL
closure (objdump BFS) + data in the compat.c layout into a
standalone tree. doc/BUILDING-WINDOWS.md section 5 documents the
flow; README points at both.

Warning: Code generated by qwen3.8-flash-next-iq3_s
libtoolize 2.4.7+ (Ubuntu 24.04) hard-errors during the
bootstrap with 'AC_CONFIG_MACRO_DIRS([m4]) conflicts with
ACLOCAL_AMFLAGS=-I m4' unless the canonical plural spelling is
used. No behavioural change on older toolchains.

Warning: Code generated by qwen3.8-flash-next-iq3_s
@csete

csete commented Nov 14, 2026

Copy link
Copy Markdown
Owner

From what I can tell, these commit were also included in #449, which has been merged.

@csete csete closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants