windows compile ncnn

Official code https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017

build tool

visual studio 2017

1. Compile protobuf

1. Download protobuf

protobuf-3.11.2:https://github.com/google/protobuf/archive/v3.11.2.zip

2. Unzip

Unzip to: D:\protobuf-3.11.2

3. Compile

open windows powershell

mkdir protobuf_build
cd protobuf_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

The Vulkan SDK is used to call the GPU, so I won’t go into details here

Two, compile opencv

1. Download cmake

Official website link: Download | CMake

2. Download opencv and opencv_contrib

opencv:Release OpenCV 4.8.0 · opencv/opencv · GitHub

opencv_contrib:Tags · opencv/opencv_contrib · GitHub

After installation, place it in the settings folder, such as,

3. Use cmake to compile opencv

source code:D:\opencv\opencv-4.8.0\sources

build the binaries:D:\opencv\tools

After setting, click configure, then select the vs version and operating system, and click finish

After the first configure, the following situation will appear,

Find "OPENCV_EXTRA_MODULES_PATH" in the red area, enter: D:\opencv\opencv_contrib-4.8.0\modules to install the corresponding version of the extension package

If you want to generate opencv_world.lib, check "BUILD_opencv_world"

Configure again, the red area will disappear,

Then generate,

Next, you can find and open the opencv solution under D:\opencv\tools: D:\opencv\tools\OpenCV.sln

Right-click the solution -> generate the solution, right-click the install of cmaketargets -> only for the project -> only generate INSTALL

3. Compile ncnn

下载源码:GitHub - Tencent/ncnn: ncnn is a high-performance neural network inference framework optimized for the mobile platform

Unzip to drive D, such as: D:\ncnn

cd D:\ncnn
mkdir -p protobuf_build
cd protobuf_build

Start compiling ncnn, 

## 注意把<protobuf-root-dir>换成你的protobuf的目录,如:D:/protobuf-3.11.2
## DNCNN_VULKAN设成OFF
## 指定DOpenCV_DIR的路径,如:D:/opencv/tools
cmake -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=D:/protobuf-3.11.2/protobuf_build/install/include -DProtobuf_LIBRARIES=D:/protobuf-3.11.2/protobuf_build/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=D:/protobuf-3.11.2/protobuf_build/install/bin/protoc.exe -DNCNN_VULKAN=OFF .. -DOpenCV_DIR=D:/opencv/tools

cmake --build . --config Release -j 2

cmake --build . --config Release --target install

So far, the compilation of ncnn on windows has been completed

Guess you like

Origin blog.csdn.net/qq_38964360/article/details/132050954