mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Use of designated initializers fails Windows build

Open definability opened this issue 9 months ago • 2 comments

OS Platform and Distribution

Windows 11

Compiler version

MSVC 19.29.30158 for x64

Programming Language and version

C++17

Installed using virtualenv? pip? Conda?(if python)

No

MediaPipe version

master (ffe429d5278b914c44fdb5df3ce38962b55580bb)

Bazel version

6.5.0

XCode and Tulsi versions (if iOS)

N/A

Android SDK and NDK versions (if android)

N/A

Android AAR (if android)

None

OpenCV version (if running on desktop)

3.4.12

Describe the problem

Build of hand_tracking_cpu example fails

bazel-6.5.0 build --verbose_failures -c opt --define MEDIAPIPE_DISABLE_GPU=1 --define=xnn_enable_avxvnniint8=false --shell_executable="C:\msys64\usr\bin\bash.exe" --repo_env=HERMETIC_PYTHON_VERSION=3.11 -- //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu

The problem was introduced in https://github.com/google-ai-edge/mediapipe/blob/ffe429d5278b914c44fdb5df3ce38962b55580bb/mediapipe/framework/output_stream_handler.cc#L145-L149

Designated initializers are a feature of C++20: https://en.cppreference.com/w/cpp/language/aggregate_initialization.

I see two ways to fix this problem, but I am unsure about the MediaPipe team's plans.

  1. Do not use designated initializers.
  2. Update the C++ version to C++20. This may require updating the codebase accordingly, and people using older compilers may have problems with it.

Complete Logs

All you need to know:

mediapipe/framework/output_stream_handler.cc(146): error C7555: use of designated initializers requires at least '/std:c++20'

definability avatar Mar 02 '25 09:03 definability

If the simple solution is satisfactory, please check out my pull request https://github.com/google-ai-edge/mediapipe/pull/5875

definability avatar Mar 02 '25 10:03 definability

@kuaashish, transitively, this issue touches everything that uses output_stream_handler->calculator_node->calculator_graph->calculator_framework: https://github.com/search?q=repo%3Agoogle-ai-edge%2Fmediapipe+%22%2F%2Fmediapipe%2Fframework%3Acalculator_framework%22&type=code

I am unsure whether legacy:hands is the correct label for this issue, as it underestimates the problem: a lot of modules cannot be built for Windows.

definability avatar Apr 16 '25 08:04 definability

For anyone facing this issue, disable 145-145. It works for me, not sure about its consequences.

Saish-in3d avatar Jul 10 '25 16:07 Saish-in3d

@Saish-in3d, I believe, the better solution is to use an ordinary constructor instead of designated initializers (and leave the functionality unchanged) rather than disabling the code. See https://github.com/google-ai-edge/mediapipe/pull/5875 for more details

definability avatar Jul 15 '25 07:07 definability

@kuaashish, the basic Hello World example fails as well with the same error without the proposed fix on the current master branch under Windows (v0.10.26):

bazel build --verbose_failures -c opt --define MEDIAPIPE_DISABLE_GPU=1 --shell_executable="C:\msys64\usr\bin\bash.exe" --repo_env=HERMETIC_PYTHON_VERSION=3.11 -- //mediapipe/examples/desktop/hello_world:hello_world

Pull request https://github.com/google-ai-edge/mediapipe/pull/5875 fixes the problem.

definability avatar Jul 16 '25 06:07 definability