概述
参考教程
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:softwaremajorMicrosoftMicrosoft Visual Studio2017VCToolsMSVC14.16.27023binHostX86x64link.exe ... (remaining 1 argument skipped)
错误信息:
ERROR: C:/users/_bazel/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:softwaremajorMicrosoftMicrosoft Visual Studio2019CommunityVCToolsMSVC14.29.30133binHostX64x64cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE ... (remaining 42 arguments skipped)
external/com_google_protobuf/srcgoogle/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/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:softwaremajorMicrosoftMicrosoft Visual Studio2019CommunityVCToolsMSVC14.29.30133binHostX64x64cl.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里面设置好路径,编译成功
hello_world
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\software\major\anaconda3\python.exe" mediapipe/examples/desktop/hello_world
set GLOG_logtostderr=1
bazel-binmediapipeexamplesdesktophello_worldhello_world.exe
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-binmediapipeexamplesdesktophand_trackinghand_tracking_cpu.exe --calculator_graph_config_file=mediapipegraphshand_trackinghand_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-binmediapipeexamplesdesktopface_detectionface_detection_cpu.exe --calculator_graph_config_file=mediapipegraphsface_detectionface_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-binmediapipeexamplesdesktopobject_detectionobject_detection_cpu.exe --calculator_graph_config_file=mediapipegraphsobject_detectionobject_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-binmediapipeexamplesdesktopobject_trackingobject_tracking_cpu.exe --calculator_graph_config_file=mediapipegraphstrackingobject_detection_tracking_desktop_live.pbtxt
iris_tracking
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\software\major\anaconda3\python.exe" mediapipe/examples/desktop/iris_tracking:iris_tracking_cpu
set GLOG_logtostderr=1
bazel-binmediapipeexamplesdesktopiris_trackingiris_tracking_cpu.exe --calculator_graph_config_file=mediapipegraphsiris_trackingiris_tracking_cpu.pbtxt
hair_segmentation
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\software\major\anaconda3\python.exe" mediapipe/examples/desktop/hair_segmentation:hair_segmentation_cpu
set GLOG_logtostderr=1
bazel-binmediapipeexamplesdesktophair_segmentationhair_segmentation_cpu.exe --calculator_graph_config_file=mediapipegraphshair_segmentationhair_segmentation_desktop_live.pbtxt
再补一篇博客,这篇博客对在Ubuntu下编译mediapipe会有帮助
MediaPipe的编译与测试_Linda Fan的博客-CSDN博客
---------------------------------------------------------------------------------------------------------------------------
下面是自己的截图
经测试,BAZEL_WINSDK_FULL_VERSION的值设置为10.0.19041.0、10.0.17763.0、10.0.16299.0、10.0.14393.0均可编译成功。
bazel环境变量的四个参数含义如下:
BAZEL_VC:存放Visual C++ Build Tools安装目录;
BAZEL_VS:Visual Studio安装目录;
BAZEL_VC_FULL_VERSION : VS2019的中vc的版本号
该版本号可以在VS2019的安装目录D:Program Files (x86)Microsoft Visual Studio2019CommunityVCRedistMSVC下找到;
BAZEL_WINSDK_FULL_VERSION:WinSDK的版本号,这可以在控制面板-程序-程序和功能中查看,找到Windows Software Development Kit,后面跟的数字就是WinSDK的版本号,如下图所示。
2022.11.25
在写python路径时,是
C://Users//AppData//Local//Continuum//anaconda3//python.exe
而不是
C:UsersAppDataLocalContinuumanaconda3python.exe
参考下面链接
An error occurred during the fetch of repository ‘local_execution_config_python‘:_慕梅^的博客-CSDN博客
2023.05.18
最后
以上就是淡定玫瑰为你收集整理的Windows下编译Mediapipe,C++版本的全部内容,希望文章能够帮你解决Windows下编译Mediapipe,C++版本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复