windows下ncnn debug编译

安装visual studio需要安装哪些,可参考“参考3”。

官网也可以下编译好的,不过是release版本,如果要用debug版本,就要自己编译了。

主要是参照官网的教程,但是也会有一些异常情况,那我就记录下我的编译过程

官网教程: https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017

这里我原先用的 visual-studio-profession-2017有问题,加上又过期,我就重新安装了community版本。

用的是下面这个来做命令行,由于我的已经打开,所以显示灰色

第一步编译protobuf,原先我是直接git clone 官网地址,然后编译一直出问题,后来我直接下载官方提供的https://github.com/google/protobuf/archive/v3.11.2.zip来编译

cd <protobuf-root-dir>
mkdir build
cd build
cmake -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
cmake --build . --config Release -j 2
cmake --build . --config Release --target install

第二步就是编译ncnn,这里我也是直接git clone 官网最新的,也出了点问题,后来我就用tag:20230223版本来编译

cd <ncnn-root-dir>
mkdir -p build
cd build
cmake -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=<protobuf-root-dir>/build/install/include -DProtobuf_LIBRARIES=<protobuf-root-dir>/build/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=<protobuf-root-dir>/build/install/bin/protoc.exe -DNCNN_VULKAN=ON ..
cmake --build . --config Release -j 2
cmake --build . --config Release --target install

当然,我没用到DNCNN_VULKAN,所以设为OFF。

如果直接用第4行编译,编译可能会报:“OpenCV not found, examples won't be built

所以我参考“参考1”博客,把设为-DNCNN_BUILD_EXAMPLES=OFF,同时参考“参考2”把-DOpenCV_DIR=D:/install-soft/opencv-3.4.11/opencv/build 设置为opencv的build这一层级。

接着还加了这个-DCMAKE_BUILD_TYPE=Debug编译debug版本,当然,protubuff也要编译对应的Debug版本库才可以,以下是编译的完整命令,主要是争对上面第4行修改。

cmake -A x64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=D:/xxx/2023coding/protobuf-3.11.2/protobuf-3.11.2/build3112/install/include -DProtobuf_LIBRARIES=D:/xxx/2023coding/protobuf-3.11.2/protobuf-3.11.2/build3112/Debug/libprotobufd.lib -DProtobuf_PROTOC_EXECUTABLE=D:/xxx/2023coding/protobuf-3.11.2/protobuf-3.11.2/build3112/Debug/protoc.exe -DNCNN_VULKAN=OFF -DNCNN_BUILD_EXAMPLES=OFF -DOpenCV_DIR=D:/install-soft/opencv-3.4.11/opencv/build ..

执行5,6行的时候,如果编译的是Debug版本,需要把Release改为Debug。

另外放一个我编译好的图片:

参考:

  1. https://blog.csdn.net/sinat_29957455/article/details/108830085

  1. https://github.com/Tencent/ncnn/issues/1982

  1. https://blog.csdn.net/yohnyang/article/details/128384633

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值