Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error when trying to build the C++ examples #5246

Open
Stoyan-I-A opened this issue Mar 20, 2024 · 7 comments
Open

Linker error when trying to build the C++ examples #5246

Stoyan-I-A opened this issue Mar 20, 2024 · 7 comments
Assignees
Labels
legacy:hands Hand tracking/gestures/etc os:windows MediaPipe issues on Windows platform:c++ Issues specific to C++ framework in mediapipe stat:awaiting googler Waiting for Google Engineer's Response type:build/install For Build and Installation issues

Comments

@Stoyan-I-A
Copy link

Stoyan-I-A commented Mar 20, 2024

OS Platform and Distribution

Windows 10

Compiler version

No response

Programming Language and version

C++ with MSVC 14.29.30133

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

No response

MediaPipe version

Cloned from the master branch

Bazel version

6.1.1

XCode and Tulsi versions (if iOS)

No response

Android SDK and NDK versions (if android)

No response

Android AAR (if android)

None

OpenCV version (if running on desktop)

3.4.10

Describe the problem

I followed the instructions to install the Mediapipe framework described here (including building the "Hello World" example). Then, I followed the instructions to build the "Hand Detection solution" using these instructions. The build failed due to a Linker error (see the output log).

Complete Logs

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\Users\sasenov\mediapipe_repo\mediapipe

C:\Users\sasenov\mediapipe_repo\mediapipe>set BAZEL_VS="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"

C:\Users\sasenov\mediapipe_repo\mediapipe>set BAZEL_VC="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC"

C:\Users\sasenov\mediapipe_repo\mediapipe>set BAZEL_VC_FULL_VERSION=14.29.30133

C:\Users\sasenov\mediapipe_repo\mediapipe>set BAZEL_WINSDK_FULL_VERSION=10.0.19041.0

C:\Users\sasenov\mediapipe_repo\mediapipe>bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu
WARNING: C:/users/sasenov/mediapipe_repo/mediapipe/mediapipe/framework/BUILD:69:24: in cc_library rule //mediapipe/framework:calculator_cc_proto: target '//mediapipe/framework:calculator_cc_proto' depends on deprecated target '@com_google_protobuf//:cc_wkt_protos': Only for backward compatibility. Do not use.
WARNING: C:/users/sasenov/mediapipe_repo/mediapipe/mediapipe/framework/tool/BUILD:200:24: in cc_library rule //mediapipe/framework/tool:field_data_cc_proto: target '//mediapipe/framework/tool:field_data_cc_proto' depends on deprecated target '@com_google_protobuf//:cc_wkt_protos': Only for backward compatibility. Do not use.
INFO: Analyzed target //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: C:/users/sasenov/mediapipe_repo/mediapipe/mediapipe/examples/desktop/hand_tracking/BUILD:31:10: Linking mediapipe/examples/desktop/hand_tracking/hand_tracking_cpu.exe failed: (Exit 1120): link.exe failed: error executing command (from target //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu) C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe ... (remaining 1 argument skipped)
   Creating library bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\hand_tracking\hand_tracking_cpu.lib and object bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\hand_tracking\hand_tracking_cpu.exp
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateOptionsDefault' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateCreate' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateDelete' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalCreate' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetInit' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetFree' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetPrepare' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetInvoke' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
op_resolver.lib(op_resolver.obj) : error LNK2019: unresolved external symbol __imp_TfLiteOpaqueContextReportError referenced in function "private: static enum TfLiteStatus __cdecl <lambda_b97dfc3d256899f307c12847116b247f>::<lambda_invoker_cdecl>(struct TfLiteOpaqueContext *,struct TfLiteOpaqueNode *)" (?<lambda_invoker_cdecl>@<lambda_b97dfc3d256899f307c12847116b247f>@@CA?AW4TfLiteStatus@@PEAUTfLiteOpaqueContext@@PEAUTfLiteOpaqueNode@@@Z)
bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\hand_tracking\hand_tracking_cpu.exe : fatal error LNK1120: 1 unresolved externals
Target //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.363s, Critical Path: 0.91s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
@Stoyan-I-A Stoyan-I-A added the type:build/install For Build and Installation issues label Mar 20, 2024
@kuaashish kuaashish added os:windows MediaPipe issues on Windows platform:c++ Issues specific to C++ framework in mediapipe legacy:hands Hand tracking/gestures/etc labels Mar 21, 2024
@chojuahn
Copy link

Same issue when building face_mesh

C:\Dev\mediapipe_cpp>bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="C:\\Users\\choju\\AppData\\Local\\Programs\\Python\\Python311\\python.exe" mediapipe/examples/desktop/face_mesh:face_mesh_cpu --verbose_failures
INFO: Analyzed target //mediapipe/examples/desktop/face_mesh:face_mesh_cpu (0 packages loaded, 0 targets configured).
ERROR: C:/dev/mediapipe_cpp/mediapipe/examples/desktop/face_mesh/BUILD:28:10: Linking mediapipe/examples/desktop/face_mesh/face_mesh_cpu.exe failed: (Exit 1120): link.exe failed: error executing CppLink command (from target //mediapipe/examples/desktop/face_mesh:face_mesh_cpu)
  cd /d C:/users/choju/_bazel_choju/4oh6ymff/execroot/_main
  SET LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
    SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;;C:\Windows\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
    SET PWD=/proc/self/cwd
    SET PYTHON_BIN_PATH=C:\\Users\\choju\\AppData\\Local\\Programs\\Python\\Python311\\python.exe
    SET RUNFILES_MANIFEST_ONLY=1
    SET TEMP=C:\Users\choju\AppData\Local\Temp
    SET TMP=C:\Users\choju\AppData\Local\Temp
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe @bazel-out/x64_windows-opt/bin/mediapipe/examples/desktop/face_mesh/face_mesh_cpu.exe-0.params
# Configuration: 746d2bf6598b4d30b02225b11bf6909d74ba6578b05e01a2753168805d86bd13
# Execution platform: @@local_execution_config_platform//:platform
   Creating library bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\face_mesh\face_mesh_cpu.lib and object bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\face_mesh\face_mesh_cpu.exp
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateOptionsDefault' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateCreate' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteXNNPackDelegateDelete' defined in 'xnnpack_delegate.lib(xnnpack_delegate.obj)' is imported by 'inference_calculator_cpu.lo.lib(inference_calculator_cpu.obj)' in function '"private: class absl::StatusOr<class std::unique_ptr<struct TfLiteDelegate,class std::function<void __cdecl(struct TfLiteDelegate *)> > > __cdecl mediapipe::api2::InferenceCalculatorCpuImpl::MaybeCreateDelegate(class mediapipe::CalculatorContext *)" (?MaybeCreateDelegate@InferenceCalculatorCpuImpl@api2@mediapipe@@AEAA?AV?$StatusOr@V?$unique_ptr@UTfLiteDelegate@@V?$function@$$A6AXPEAUTfLiteDelegate@@@Z@std@@@std@@@absl@@PEAVCalculatorContext@3@@Z)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalCreate' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetInit' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetFree' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetPrepare' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
LINK : warning LNK4217: symbol 'TfLiteRegistrationExternalSetInvoke' defined in 'registration_external.lo.lib(registration_external.obj)' is imported by 'op_resolver.lib(op_resolver.obj)' in function '"public: __cdecl mediapipe::OpResolver::OpResolver(void)" (??0OpResolver@mediapipe@@QEAA@XZ)'
op_resolver.lib(op_resolver.obj) : error LNK2019: unresolved external symbol __imp_TfLiteOpaqueContextReportError referenced in function "private: static enum TfLiteStatus __cdecl <lambda_cfab14606fe5cecdc70fbc1dd29e189c>::<lambda_invoker_cdecl>(struct TfLiteOpaqueContext *,struct TfLiteOpaqueNode *)" (?<lambda_invoker_cdecl>@<lambda_cfab14606fe5cecdc70fbc1dd29e189c>@@CA?AW4TfLiteStatus@@PEAUTfLiteOpaqueContext@@PEAUTfLiteOpaqueNode@@@Z)
bazel-out\x64_windows-opt\bin\mediapipe\examples\desktop\face_mesh\face_mesh_cpu.exe : fatal error LNK1120: 1 unresolved externals
Target //mediapipe/examples/desktop/face_mesh:face_mesh_cpu failed to build
INFO: Elapsed time: 1.100s, Critical Path: 0.86s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully```

@chojuahn
Copy link

For some reason the function body TfLiteOpaqueContextReportError inside mediapipe_cpp\bazel-mediapipe_cpp\external\org_tensorflow\tensorflow\lite\core\c\c_api_opaque.cc not built?

@Stoyan-I-A
Copy link
Author

Same issue when building face_mesh

Indeed, I wasn't able to build any of the examples other than "Hello World".

@Stoyan-I-A Stoyan-I-A changed the title Linker error when trying to build the C++ exemples Linker error when trying to build the C++ examples Mar 22, 2024
@chojuahn
Copy link

Same issue when building face_mesh

Indeed, I wasn't able to build any of the examples other than "Hello World".

face_detection is buildable as is

@Stoyan-I-A
Copy link
Author

@chojuahn You are right! I didn't try this one. I had to mess around with the files afterwards to launch the .exe but it does build indeed.

@chojuahn
Copy link

A workaround, comment out here

+++ b/mediapipe/util/tflite/op_resolver.cc
@@ -52,8 +52,8 @@ TfLiteRegistration* RegisterMaxPoolingWithArgmax2D() {
            TfLiteOpaqueNode* node) -> TfLiteStatus { return kTfLiteOk; });
     TfLiteRegistrationExternalSetInvoke(
         r, [](TfLiteOpaqueContext* context, TfLiteOpaqueNode*) -> TfLiteStatus {
-          TfLiteOpaqueContextReportError(
-              context, "MaxPoolingWithArgmax2D is only available on the GPU.");
+          // TfLiteOpaqueContextReportError(
+          //    context, "MaxPoolingWithArgmax2D is only available on the GPU.");
           return kTfLiteError;
         });
     return r;```

@schmidt-sebastian schmidt-sebastian self-assigned this Apr 1, 2024
@schmidt-sebastian
Copy link
Collaborator

This is also breaking MediaPipe's Python build for Windows. I am trying to track it down.

The offending commit is tensorflow/tensorflow@d6e25b0, though there doesn't seem to be an obvious problem with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:hands Hand tracking/gestures/etc os:windows MediaPipe issues on Windows platform:c++ Issues specific to C++ framework in mediapipe stat:awaiting googler Waiting for Google Engineer's Response type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

4 participants