参考教程
1、Mediapipe - Windows10 编译Mediapipe C++版本保姆级教程_HW140701的博客-CSDN博客_mediapipe win10
2、Windows下编译C++ MediaPipe_木火火ZERO的博客-CSDN博客_windows 下编译c++
先是按照教程1进行编译hello_world,
VS2017社区版、opencv4.4.0(编译hello_world时没用到opencv,在编译hello_world时没出错误)、
bazel5.2.0
出现了很多LINK2005的错误,然后参考教程2,换成了VS2019社区版,又出现了下面的错误
错误信息:
D:/file/mediapipe/mediapipe-master/mediapipe/examples/desktop/hello_world/BUILD:19:10: Linking mediapipe/examples/desktop/hello_world/hello_world.exe failed: (Exit 1169): link.exe failed: error executing command (from target //mediapipe/examples/desktop/hello_world:hello_world) D:\software\major\Microsoft\Microsoft Visual Studio\2017\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe ... (remaining 1 argument skipped)
错误信息:
ERROR: C:/users/_bazel_gjmhs4/5w3fxdmf/external/com_google_protobuf/BUILD:208:11: Compiling src/google/protobuf/util/time_util.cc [for tool] failed: (Exit 2): cl.exe failed: error executing command (from target @com_google_protobuf//:protobuf) D:\software\major\Microsoft\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE ... (remaining 42 arguments skipped)
external/com_google_protobuf/src\google/protobuf/util/time_util.h(47): fatal error C1083: 无法打开包括文件: “winsock2.h”: No such file or directory
Target //mediapipe/examples/desktop/hello_world:hello_world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.042s, Critical Path: 0.79s
INFO: 130 processes: 129 internal, 1 local.
FAILED: Build did NOT complete successfully
错误信息
C:/users/_bazel_gjmhs4/5w3fxdmf/external/com_google_protobuf/BUILD:155:11: Compiling src/google/protobuf/stubs/common.cc failed: (Exit 2): cl.exe failed: error executing command D:\software\major\Microsoft\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE ... (remaining 42 arguments skipped)
来回切换VS版本、python版本,还是出现同样的问题
然后搜索到下面几个网页
用户对问题“升级Visual Studio后Bazel不再工作”的回答 - 问答 - 腾讯云开发者社区-腾讯云
Bazel is not working with visual studio 2019 · Issue #8589 · bazelbuild/bazel · GitHub
Windows: Add BAZEL_VC_FULL_VERSION for windows cc configuration · bazelbuild/bazel@e5b7bd6 · GitHub
我想到可能是bazel变量设置的问题,
我想是不是把,BAZEL_WINSDK_FULL_VERSION的值设置的高了,把这个值降低一点
我改成了10.0.17763.0,再次编译,成功编译了hello_world
我想原来是没有仔细看教程2的说明,
在系统变量里面,我写的BAZEL_WINSDK_FULL_VERSION的值是10.0.19041.685,才导致了这个问题的出现,应该是10.0.19041.0
------------------------------------------------------------------------------------------------------------------
然后接着编译hand_tracking,错误,提示opencv3.4.10,然后把opencv改成3.4.10,workspace里面设置好路径,编译成功
hand_tracking
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\\software\\major\\anaconda3\\python.exe" mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu
set GLOG_logtostderr=1
bazel-bin\mediapipe\examples\desktop\hand_tracking\hand_tracking_cpu.exe --calculator_graph_config_file=mediapipe\graphs\hand_tracking\hand_tracking_desktop_live.pbtxt
face_detection
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\\software\\major\\anaconda3\\python.exe" mediapipe/examples/desktop/face_detection:face_detection_cpu
set GLOG_logtostderr=1
bazel-bin\mediapipe\examples\desktop\face_detection\face_detection_cpu.exe --calculator_graph_config_file=mediapipe\graphs\face_detection\face_detection_desktop_live.pbtxt
object_detection
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\\software\\major\\anaconda3\\python.exe" mediapipe/examples/desktop/object_detection:object_detection_cpu
set GLOG_logtostderr=1
bazel-bin\mediapipe\examples\desktop\object_detection\object_detection_cpu.exe --calculator_graph_config_file=mediapipe\graphs\object_detection\object_detection_desktop_live.pbtxt
object_tracking
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\\software\\major\\anaconda3\\python.exe" mediapipe/examples/desktop/object_tracking:object_tracking_cpu
set GLOG_logtostderr=1
bazel-bin\mediapipe\examples\desktop\object_tracking\object_tracking_cpu.exe --calculator_graph_config_file=mediapipe\graphs\tracking\object_detection_tracking_desktop_live.pbtxt
再补一篇博客,这篇博客对在Ubuntu下编译mediapipe会有帮助
MediaPipe的编译与测试_Linda Fan的博客-CSDN博客