最近一个项目需要用到ncnn
依赖库为x86
版本的,无奈只能自己动手编译一下。
我之前按照官方示例,编译过ncnn
的Release x64
版本的,大体过程其实差不多。链接:
https://blog.csdn.net/Star_ID/article/details/124166672
预先准备好:
VS2019
CMake3.21.3
ncnn
源码:https://github.com/Tencent/ncnnprotobuf3.4.0
源码:https://github.com/google/protobuf/archive/v3.4.0.zip
编译protobuf
以管理员身份打开x86 Native Tools Command Prompt for VS 2019
。注意,将DCMAKE_BUILD_TYPE
改成Debug
cd <protobuf-root-dir>
mkdir build-vs2019
cd build-vs2019
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
nmake
nmake install
nmake
nmake install
编译ncnn
以管理员身份打开x86 Native Tools Command Prompt for VS 2019
,构建ncnn
。注意,将DCMAKE_BUILD_TYPE
改成Debug
cd <ncnn-root-dir>
mkdir build
cd build
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=D:/ncnnx86debug/protobuf-3.4.0/build-vs2019/install/include -DProtobuf_LIBRARIES=D:/ncnnx86debug/protobuf-3.4.0/build-vs2019/install/lib/libprotobufd.lib -DProtobuf_PROTOC_EXECUTABLE=D:/ncnnx86debug/protobuf-3.4.0/build-vs2019/install/bin/protoc.exe -DNCNN_VULKAN=off ..
nmake
nmake install
nmake
nmake install
得到编译好的debug x86
文件