启动VS2022 下面的 x64 Native Tools Command Prompt for VS2022
protobuf
git clone git@github.com:protocolbuffers/protobuf.git# 或者 下载 https://github.com/google/protobuf/archive/v3.11.2.zip
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
抽取include文件出来,为下一步编译做打算
$ ncnn_deploy\protobuf\build_vs2022\extract_includes.bat
ncnn
git clone git@github.com:Tencent/ncnn.git
cd ncnn
git submodule update --init
mkdir build
cd build
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=E:/cpp_code/protobuf/build_vs2022/install/include -DProtobuf_LIBRARIES=E:/cpp_code/protobuf/build_vs2022/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=E:/cpp_code/protobuf/build_vs2022/install/bin/protoc.exe -DNCNN_VULKAN=ON ..
nmake
nmake install
如果git submodule update --init执行不成功的话,
git clone git@github.com:Tencent/ncnn.git
cd ncnn
mkdir build
cd build
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=ncnn_deploy/protobuf/build_vs2022/install/include -DProtobuf_LIBRARIES=ncnn_deploy/protobuf/build_vs2022/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=ncnn_deploy/protobuf/build_vs2022/install/bin/protoc.exe -DNCNN_VULKAN=OFF ..
nmake
nmake install
1 复制 include
复制 ncnn\build\install\include目录内容 到ncnn_vs2022\include下
2 复制 lib
复制 ncnn\build\install\lib\ncnn.lib到ncnn_vs2022\lib
3 复制 exe
复制 ncnn\build\install\bin下 onnx2ncnn.exe 到ncnn_vs2022\exe
复制 ncnn\build\install\bin下ncnn2int8.exe 到ncnn_vs2022\exe
复制 ncnn\build\install\bin下ncnn2mem.exe 到ncnn_vs2022\exe
复制 ncnn\build\install\bin下ncnn2table.exe 到ncnn_vs2022\exe
复制 ncnn\build\install\bin下ncnnmerge.exe 到ncnn_vs2022\exe
复制 ncnn\build\install\bin下ncnnoptimize.exe 到ncnn_vs2022\exe