mirror of
https://github.com/Z3Prover/z3
synced 2026-08-04 05:03:30 +00:00
Fix MinGW linker errors: explicitly link dbghelp on Windows (#10203)
Building Z3 on Windows with MinGW (`mingw-w64-ucrt-x86_64-gcc`) fails with undefined references to `SymSetOptions`, `SymInitialize`, `SymFromAddr`, and `SymGetLineFromAddr64` from the DbgHelp library used in `src/util/debug.cpp` for stack backtraces. The existing `#pragma comment(lib, "dbghelp.lib")` in `debug.cpp` is an MSVC-only extension — MinGW silently ignores it, so `dbghelp` is never passed to the linker. ## Changes - **`CMakeLists.txt`**: Append `dbghelp` to `Z3_DEPENDENT_LIBS` in the `WIN32` platform block. This feeds the library to both the `libz3` and `shell` link steps regardless of compiler. - **`src/util/debug.cpp`**: Guard the `#pragma comment` with `#ifdef _MSC_VER` to make the MSVC-only intent explicit. <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #10171 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
parent
d247df72a2
commit
44c221b690
2 changed files with 7 additions and 1 deletions
|
|
@ -39,7 +39,9 @@ bool assertions_enabled() {
|
|||
#if defined(_WINDOWS)
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
#endif
|
||||
static void print_windows_backtrace() {
|
||||
HANDLE process = GetCurrentProcess();
|
||||
SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue