From a2391587c723932bde7df6a6005feef9f21fa40f Mon Sep 17 00:00:00 2001 From: JustVugg Date: Wed, 15 Jul 2026 22:52:17 +0200 Subject: [PATCH] Makefile(win): link -lpsapi so the MinGW build resolves GetProcessMemoryInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compat.h's rss_gb() calls GetProcessMemoryInfo and links psapi via #pragma comment(lib,"psapi.lib") — an MSVC-ism. MinGW gcc ignores that pragma (emits -Wunknown-pragmas), and the Windows LDFLAGS never linked psapi, so on a gcc that doesn't honor the pragma (e.g. 16.1.0 UCRT) the build fails with `undefined reference to GetProcessMemoryInfo`. Add -lpsapi to the Windows LDFLAGS; harmless on toolchains where the pragma also resolves it. Found while building on native Windows 11 with winlibs GCC 16.1. Co-Authored-By: Claude Opus 4.8 --- c/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c/Makefile b/c/Makefile index 19f827b..f98e541 100644 --- a/c/Makefile +++ b/c/Makefile @@ -67,7 +67,11 @@ else ifneq ($(IS_WIN),) CC = gcc ARCH ?= x86-64-v3 CFLAGS = -D_FILE_OFFSET_BITS=64 -O3 -march=$(ARCH) -fopenmp -Wall -Wextra -Wno-unused-parameter -Wno-misleading-indentation -Wno-unused-function -LDFLAGS = -lm -fopenmp -static +# -lpsapi: compat.h calls GetProcessMemoryInfo (rss_gb). It's linked via +# #pragma comment(lib,"psapi.lib") for MSVC, but MinGW gcc ignores that pragma +# (warns), so link psapi explicitly or the build fails undefined-reference on +# modern GCC (e.g. 16.x under UCRT). Harmless where the pragma also resolves it. +LDFLAGS = -lm -fopenmp -static -lpsapi EXE = .exe else ifneq (,$(PPC64))