在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