在win10+vs2015环境下编译配置ncnn。
ncnn由腾讯推出, 是一个为手机端极致优化的高性能神经网络前向计算框架。ncnn 从设计之初深刻考虑手机端的部署和使用。无第三方依赖,跨平台,手机端 cpu 的速度快于目前所有已知的开源框架。基于 ncnn,开发者能够将深度学习算法轻松移植到手机端高效执行。
网址:https://github.com/Tencent/ncnn
1、protobuf编译
下载protobuf :https://github.com/google/protobuf/archive/v3.4.0.zip
下载完后解压,然后打开VS2015 X64本机工具命令提示符:
之后进入压缩目录,执行如下命令:
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install ^
-Dprotobuf_BUILD_TESTS=OFF ^
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
nmake
nmake install
出现以下界面,即安装成功:
2、编译ncnn
1)下载ncnn源码:https://github.com/Tencent/ncnn/releases
2)下载绿色框中的代码,并解压,进入ncnn目录创建build文件夹:
mkdir -p build-vs2015
cd build-vs2015
3)输入下列命令:
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=D:/thirdLib/ncnn/protobuf-3.4.0/build-2015/install/include -DProtobuf_LIBRARIES=D:/thirdLib/ncnn/protobuf-3.4.0/build-2015/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=D:/thirdLib/ncnn/protobuf-3.4.0/build-2015/install/bin/protoc.exe ..
nmake
nmake install
出现以下界面,表示编译成功:
3、配置vs2015
1)VS2015新建一个C++项目,打开“属性管理器”
2)如需添加Release x64版本,则选中Release|x64,右键,选择”添加新项目属性表“,修改名字和路径,保存,双击打开。
3)选择“c/c++”->”常规“,”附加包含目录 “中添加:
D:\thirdLib\ncnn\protobuf-3.4.0\build-2015\install\include
D:\thirdLib\ncnn\ncnn-20191113\build-2015\install\include
4)选择“链接器”->”常规“,”附加库目录 “中添加:
D:\thirdLib\ncnn\protobuf-3.4.0\build-2015\install\lib
D:\thirdLib\ncnn\ncnn-20191113\build-2015\install\lib
5)选择“链接器”->”输入“,”附加依赖项 “中添加:
libprotobuf.lib
ncnn.lib