Skip to content

Fix Windows Build: Add /Zc:preprocessor, Pin Python 3.12, Fix constinit#6238

Open
SriHarsha-23 wants to merge 2 commits intogoogle-ai-edge:masterfrom
SriHarsha-23:fix-windows-msvc-build
Open

Fix Windows Build: Add /Zc:preprocessor, Pin Python 3.12, Fix constinit#6238
SriHarsha-23 wants to merge 2 commits intogoogle-ai-edge:masterfrom
SriHarsha-23:fix-windows-msvc-build

Conversation

@SriHarsha-23
Copy link
Copy Markdown

This PR fixes the default build on Windows (MSVC 2022 + Bazel 9), addressing multiple compile-time errors.

Issues Fixed

  1. Python 3.13 Compatibility:

    • Error: Could not find requirements_lock.txt file matching specified Python version: 3.13
    • Fix: Added build:windows --repo_env=HERMETIC_PYTHON_VERSION=3.12 to .bazelrc. This forces the build to use a supported Python version, preventing crashes on systems where Python 3.13 is the default.
  2. MSVC Preprocessor Error:

    • Error: MP_STATUS_MACROS_IMPL_REM: undeclared identifier
    • Fix: Added build:windows --copt=/Zc:preprocessor to .bazelrc. The MSVC legacy preprocessor fails to expand MediaPipe's status macros correctly. Enabling the standard-conforming preprocessor fixes this.
  3. constinit Mismatch:

    • Error: C2475: 'mediapipe::kGpuService': redefinition; 'constinit' specifier mismatch
    • Fix: Added constinit to kGpuService in both mediapipe/gpu/gpu_service.h and mediapipe/gpu/gpu_service.cc to ensure the declaration and definition match, satisfying the MSVC compiler strictness.

Verification

Verified by successfully building and running the hello_world example on Windows 11 with Visual Studio 2022.

Closes #5748
Closes #6176

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.

Missing files during build Error building on windows 11 (maybe docs is out of date?)

1 participant