Windows下编译Mediapipe,C++版本

参考教程

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/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/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里面设置好路径,编译成功

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-bin\mediapipe\examples\desktop\hello_world\hello_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-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

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-bin\mediapipe\examples\desktop\iris_tracking\iris_tracking_cpu.exe --calculator_graph_config_file=mediapipe\graphs\iris_tracking\iris_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-bin\mediapipe\examples\desktop\hair_segmentation\hair_segmentation_cpu.exe --calculator_graph_config_file=mediapipe\graphs\hair_segmentation\hair_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 Studio\2019\Community\VC\Redist\MSVC下找到;

BAZEL_WINSDK_FULL_VERSION:WinSDK的版本号,这可以在控制面板-程序-程序和功能中查看,找到Windows Software Development Kit,后面跟的数字就是WinSDK的版本号,如下图所示。

2022.11.25

在写python路径时,是

C://Users//AppData//Local//Continuum//anaconda3//python.exe

而不是


C:\Users\AppData\Local\Continuum\anaconda3\python.exe

参考下面链接

An error occurred during the fetch of repository ‘local_execution_config_python‘:_慕梅^的博客-CSDN博客

2023.05.18

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值