rajkundu/mediapipe

Linker Error on VS 2022 17.4+

rajkundu opened this issue · 1 comments

When building MediaPipe on Windows with VS 2022 17.4 or higher, a linker error occurs similar to the following:

face_detection_options_registry.lo.lib(face_detection_options_lib.obj) : error LNK2019: unresolved external symbol "private: static class RegistrationToken::RegistrationToken const mediapipe::tool::OptionsRegistry::registration_token" (??$registration_token@VFaceDetectionOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@0VRegistrationToken@3@B) referenced in function "??__E?$registration_token@VFaceDetectionOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@yaxxz" (??__E?$registration_token@VFaceDetectionOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@yaxxz)

inference_calculator_options_registry.lo.lib(inference_calculator_options_lib.obj) : error LNK2019: unresolved external symbol "private: static class RegistrationToken::RegistrationToken const mediapipe::tool::OptionsRegistry::registration_token" (??$registration_token@VInferenceCalculatorOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@0VRegistrationToken@3@B) referenced in function "??__E?$registration_token@VInferenceCalculatorOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@yaxxz" (??__E?$registration_token@VInferenceCalculatorOptions@mediapipe@@@OptionsRegistry@tool@mediapipe@@yaxxz)

bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\face_detection\face_detection_cpu.exe : fatal error LNK1120: 2 unresolved externals

See the following links for more details:

The current best workaround is to use an older version of VS, such as VS 2019, VS 2022 17.3.7 or below, etc.

Microsoft has stated that the underlying bug in VS 2022 and has been fixed in version 17.6, and I have confirmed this by successfully compiling LibMP with VS 2022 17.6 Preview 1. So, the permanent solution is to avoid using VS 2022 17.4.x & 17.5.x and either use VS 2022 <=17.3 or >=17.6 upon release.