Skip to content

Add MinGW (GCC) build support on Windows - #176

Open
DUDUACM wants to merge 1 commit into
mvrdevelopment:masterfrom
DUDUACM:mingw-build-support
Open

Add MinGW (GCC) build support on Windows#176
DUDUACM wants to merge 1 commit into
mvrdevelopment:masterfrom
DUDUACM:mingw-build-support

Conversation

@DUDUACM

@DUDUACM DUDUACM commented Aug 20, 2026

Copy link
Copy Markdown
  • src/MCFloat.h: #undef FP_SNAN/FP_QNAN under MinGW only - mingw-w64's math.h defines them as macros (MSVC does not), breaking the enum
  • mdns_cpp/src/mdns.cpp: use in4addr_any only when compiling with MSVC; the constant is not declared in mingw-w64 headers, fall back to INADDR_ANY which is equivalent and portable
  • CMakeLists.txt:
    • call project() early so the compiler is identified before the MSVC runtime flag setup, and keep those flags inherited by mdns_cpp
    • apply WIN_RUNTIME_LIB (-MD/-MT) flags only for MSVC; GCC rejects -MDd (invalid in Debug builds)
    • link mswsock when not using MSVC: boost::asio needs AcceptEx/GetAcceptExSockaddrs, which MSVC auto-links via #pragma comment(lib) in the asio headers but MinGW does not
    • fix Windows UNITTEST executable name: get_target_property on the unset OUTPUT_NAME returned NOTFOUND, producing an executable named "OUTPUT_NAME_OLD-NOTFOUND-MD.exe"

Verified with xerces-c 3.3.0 + boost 1.86.0 + MVR_XChange + unit tests: MSVC Release/Debug and MinGW GCC 13.1 Release/Debug all build and pass all 27 unit test suites. No behavior change for MSVC builds.

- src/MCFloat.h: #undef FP_SNAN/FP_QNAN under MinGW only - mingw-w64's
  math.h defines them as macros (MSVC does not), breaking the enum
- mdns_cpp/src/mdns.cpp: use in4addr_any only when compiling with MSVC;
  the constant is not declared in mingw-w64 headers, fall back to
  INADDR_ANY which is equivalent and portable
- CMakeLists.txt:
  - call project() early so the compiler is identified before the MSVC
    runtime flag setup, and keep those flags inherited by mdns_cpp
  - apply WIN_RUNTIME_LIB (-MD/-MT) flags only for MSVC; GCC rejects
    -MDd (invalid in Debug builds)
  - link mswsock when not using MSVC: boost::asio needs
    AcceptEx/GetAcceptExSockaddrs, which MSVC auto-links via
    #pragma comment(lib) in the asio headers but MinGW does not
  - fix Windows UNITTEST executable name: get_target_property on the
    unset OUTPUT_NAME returned NOTFOUND, producing an executable named
    "OUTPUT_NAME_OLD-NOTFOUND-MD.exe"

Verified with xerces-c 3.3.0 + boost 1.86.0 + MVR_XChange + unit tests:
MSVC Release/Debug and MinGW GCC 13.1 Release/Debug all build and pass
all 27 unit test suites. No behavior change for MSVC builds.
@welcome

welcome Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! Please check out our contributing guidelines.

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.

1 participant