Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wjd2002
Ncnn
提交
f9180330
N
Ncnn
项目概览
wjd2002
/
Ncnn
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Ncnn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f9180330
编写于
4月 23, 2023
作者:
H
He Yang
提交者:
GitHub
4月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update how-to-build.md and delete obsolete tutorials in docs (#4660)
上级
bd15e325
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
3 addition
and
282 deletion
+3
-282
docs/how-to-build/build-for-VisualStudio.en.md
docs/how-to-build/build-for-VisualStudio.en.md
+0
-140
docs/how-to-build/build-for-VisualStudio.zh.md
docs/how-to-build/build-for-VisualStudio.zh.md
+0
-139
docs/how-to-build/how-to-build.md
docs/how-to-build/how-to-build.md
+3
-3
未找到文件。
docs/how-to-build/build-for-VisualStudio.en.md
已删除
100644 → 0
浏览文件 @
bd15e325
# Compile with Visual Studio
[TOC]
## Prepare
Community Edition version of Visual Studio 2015 / 2017 / 2019 /
**2022**
Preview, using dynamic CRT runtime
CMake, version >= 3.17 recommended
## Compiling
### minimal compilation
https://github.com/Tencent/ncnn.git
#### command prompt version
```
batch
mkdir
build
-vs
2022
cd
build
-vs
2022
cmake
-G
"Visual Studio 17 2022"
-A
x64
..
cmake
--build
.
--config
Release
cmake
--install
.
--config
Release
cmake
--build
.
--config
Debug
cmake
--install
.
--config
Debug
```
It will be installed in build-vs2022/install, and the debug version of the library will have a
`d`
suffix.
#### x64 native tools command prompt version (no x64 for VS2022)
ncnn
protobuf defines parameters with reference to the following
```
batch
mkdir
build
-vs
2022
cd
build
-vs
2022
cmake
..
cmake
--build
.
cmake
--install
.
--config
Debug
//
The
default
build
generates
the
Debug
version
;
the
default
install
installs
the
Release
version
.
Refer
to
the
command
prompt
version
```
### Compile and install the ncnn library with Vulkan support
#### Device and Vulkan preparation
Confirm that the device supports Vulkan, and install the graphics driver.
Download and install the Vulkan SDK : https://vulkan.lunarg.com/sdk/home
Along with submodules, get the source code:
-
The "ncnn-YYYYMMDD-full-source.zip" download can be found at http://github.com/Tencent/ncnn/releases
-
Or get the latest version with git:
```
batch
git
clone
https
://github.com/tencent/ncnn
git
submodule
update
--init
```
#### Compile and install ncnn
```
batch
mkdir
build
-vs
2022
cd
build
-vs
2022
cmake
-G
"Visual Studio 17 2022"
-A
x64
-DCMAKE
_INSTALL_PREFIX
=
"
%cd%
/install"
-DNCNN
_VULKAN
=
ON
cmake
--build
.
--config
Release
cmake
--install
.
--config
Release
cmake
--build
.
--config
Debug
cmake
--install
.
--config
Debug
```
### Compile and install ncnn library and model conversion tool
-
This step is used to compile the model conversion tool, which can be skipped and converted directly using the https://convertmodel.com tool
-
The following command lines all use
**x64 Native Tools Command Prompt for VS 2022**
*Note: If it is done in cmd / PowerShell, it needs to be modified:*
-
`-G"NMake Makefile"`
Change to a suitable Generator such as
`-G "Visual Studio 17 2022" -A x64`
-
`nmake`
change to
`cmake --build . --config Release`
, or open
`.sln`
manually trigger the build of
`protobuf`
/
`ncnn`
items
-
`nmake install`
change to
`cmake --install . --config Release`
or open
`.sln`
manually trigger the build of
`INSTALL`
items
#### Compile and install protobuf
Tools for generating caffe2ncnn and onnx2ncnn
https://github.com/google/protobuf/archive/v3.4.0.zip
Download it to C:/Users/{{user-name}}/source and unzipped it
```
batch
mkdir
build
-vs
2022
cd
build
-vs
2022
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
```
protobuf will be installed in build-vs2022/install
#### Compile and install ncnn
https://github.com/Tencent/ncnn.git
The protobuf path in the cmake command should be modified accordingly to its own
```
batch
mkdir
build
-vs
2022
cd
build
-vs
2022
cmake
-G
"NMake Makefiles"
-DCMAKE
_BUILD_TYPE
=
Release
-DCMAKE
_INSTALL_PREFIX
=
"
%cd%
/install"
^
-DProtobuf
_INCLUDE_DIR
=
C
:/Users/
{{
user
-name
}}
/source/protobuf
-
3
.4.0/build
-vs
2022
/install/include
^
-DProtobuf
_LIBRARIES
=
C
:/Users/
{{
user
-name
}}
/source/protobuf
-
3
.4.0/build
-vs
2022
/install/lib/libprotobuf
.lib
^
-DProtobuf
_PROTOC_EXECUTABLE
=
C
:/Users/
{{
user
-name
}}
/source/protobuf
-
3
.4.0/build
-vs
2022
/install/bin/protoc
.exe ..
nmake
nmake
install
```
ncnn will be installed in build-vs2022/install
The ncnn conversion tool is in build-vs2022/tools
#### mlir2ncnn
see
[
build-mlir2ncnn
](
build-mlir2ncnn.md
)
## Use the compiled ncnn library
Write in CMakeLists
```
cmake
set
(
ncnn_DIR
"C:/Users/{{user-name}}/source/ncnn/build-vs2022/install/lib/cmake/ncnn"
CACHE PATH
"Directory containing ncnnConfig.cmake"
)
find_package
(
ncnn REQUIRED
)
target_link_libraries
(
my_target ncnn
)
```
Learn more about
[
use-ncnn-with-own-project
](
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-own-project
)
docs/how-to-build/build-for-VisualStudio.zh.md
已删除
100644 → 0
浏览文件 @
bd15e325
# 用 Visual Studio 编译
[TOC]
## 预先准备
Visual Studio 2015 / 2017 / 2019 / 2022 Preview 的 Community Edition 版本, 使用动态的 CRT 运行库
CMake, 推荐 >= 3.17 的版本
## 开始编译
### 最简编译
https://github.com/Tencent/ncnn.git
#### 命令提示符版本
```
batch
mkdir
build
-vs
2019
cd
build
-vs
2019
cmake
-G
"Visual Studio 16 2019"
-A
x64
..
cmake
--build
.
--config
Release
cmake
--install
.
--config
Release
cmake
--build
.
--config
Debug
cmake
--install
.
--config
Debug
```
会安装在 build-vs2019/install 里头,debug 版本的库会带有
`d`
后缀。
#### x64 本机工具命令提示符 版本 (VS2022无X64)
ncnn
protobuf参照后文定义参数
```
batch
mkdir
build
-vs
2019
cd
build
-vs
2019
cmake
..
cmake
--build
.
cmake
--install
.
--config
Debug
//默认build生成Debug版本;默认install安装Relase版本。 参照命令提示符版本
```
### 编译安装带 Vulkan 支持的 ncnn 库
#### 设备和 Vulkan 准备
确认设备支持 Vulkan, 安装显卡驱动。
下载和安装 Vulkan SDK: https://vulkan.lunarg.com/sdk/home
连同子模块一起,获取源码:
-
可从 http://github.com/Tencent/ncnn/releases 找到 "ncnn-YYYYMMDD-full-source.zip" 下载
-
或用 git 获取最新版本:
```
batch
git
clone
https
://github.com/tencent/ncnn
git
submodule
update
--init
```
#### 编译安装 ncnn
```
batch
mkdir
build
-vs
2019
cd
build
-vs
2019
cmake
-G
"Visual Studio 16 2019"
-A
x64
-DCMAKE
_INSTALL_PREFIX
=
"
%cd%
/install"
-DNCNN
_VULKAN
=
ON
cmake
--build
.
--config
Release
cmake
--install
.
--config
Release
cmake
--build
.
--config
Debug
cmake
--install
.
--config
Debug
```
### 编译安装 ncnn 库和模型转换工具
-
此步骤用于编译模型转换工具,可跳过,直接使用 https://convertmodel.com 工具转换
-
以下命令行均使用
**适用于 VS 2019 的 x64 本机工具命令提示**
*注:若在 cmd / PowerShell 进行,需修改:*
-
`-G"NMake Makefile"`
改为合适的 Generator 如
`-G "Visual Studio 16 2019" -A x64`
-
`nmake`
改为
`cmake --build . --config Release`
, 或打开
`.sln`
手动触发
`protobuf`
/
`ncnn`
项的构建
-
`nmake install`
改为
`cmake --install . --config Release`
,或打开
`.sln`
手动触发
`INSTALL`
项的构建
#### 编译安装 protobuf
用于生成 caffe2ncnn 和 onnx2ncnn 工具
https://github.com/google/protobuf/archive/v3.4.0.zip
我下载到 C:/Users/shuiz/source 解压缩
```
batch
mkdir
build
-vs
2019
cd
build
-vs
2019
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
```
protobuf 会安装在 build-vs2019/install 里头
#### 编译安装 ncnn
https://github.com/Tencent/ncnn.git
cmake 命令中的 protobuf 路径要相应修改成自己的
```
batch
mkdir
build
-vs
2019
cd
build
-vs
2019
cmake
-G
"NMake Makefiles"
-DCMAKE
_BUILD_TYPE
=
Release
-DCMAKE
_INSTALL_PREFIX
=
"
%cd%
/install"
^
-DProtobuf
_INCLUDE_DIR
=
C
:/Users/shuiz/source/protobuf
-
3
.4.0/build
-vs
2019
/install/include
^
-DProtobuf
_LIBRARIES
=
C
:/Users/shuiz/source/protobuf
-
3
.4.0/build
-vs
2019
/install/lib/libprotobuf
.lib
^
-DProtobuf
_PROTOC_EXECUTABLE
=
C
:/Users/shuiz/source/protobuf
-
3
.4.0/build
-vs
2019
/install/bin/protoc
.exe ..
nmake
nmake
install
```
ncnn 会安装在 build-vs2019/install 里头
ncnn 转换工具在 build-vs2019/tools 里头
#### mlir2ncnn
见
[
build-mlir2ncnn
](
build-mlir2ncnn.md
)
## 使用编译好的 ncnn 库
CMakeLists 里写
```
cmake
set
(
ncnn_DIR
"C:/Users/shuiz/source/ncnn/build-vs2019/install/lib/cmake/ncnn"
CACHE PATH
"包含 ncnnConfig.cmake 的目录"
)
find_package
(
ncnn REQUIRED
)
target_link_libraries
(
my_target ncnn
)
```
进一步了解
[
use-ncnn-with-own-project
](
../how-to-use-and-FAQ/use-ncnn-with-own-project.md
)
docs/how-to-build/how-to-build.md
浏览文件 @
f9180330
...
...
@@ -147,9 +147,9 @@ Build ncnn library (replace <protobuf-root-dir> with a proper path):
```
shell
cd
<ncnn-root-dir>
mkdir
-p
build
cd
build
cmake
-A
x64
-DCMAKE_INSTALL_PREFIX
=
%cd%/install
-DProtobuf_INCLUDE_DIR
=
<protobuf-root-dir>/
build/install/include
-DProtobuf_LIBRARIES
=
<protobuf-root-dir>/build/install/lib/libprotobuf.lib
-DProtobuf_PROTOC_EXECUTABLE
=
<protobuf-root-dir>/
build/install/bin/protoc.exe
-DNCNN_VULKAN
=
ON ..
mkdir
-p
protobuf_
build
cd
protobuf_
build
cmake
-A
x64
-DCMAKE_INSTALL_PREFIX
=
%cd%/install
-DProtobuf_INCLUDE_DIR
=
<protobuf-root-dir>/
protobuf_build/install/include
-DProtobuf_LIBRARIES
=
<protobuf-root-dir>/protobuf_build/install/lib/libprotobuf.lib
-DProtobuf_PROTOC_EXECUTABLE
=
<protobuf-root-dir>/protobuf_
build/install/bin/protoc.exe
-DNCNN_VULKAN
=
ON ..
cmake
--build
.
--config
Release
-j
2
cmake
--build
.
--config
Release
--target
install
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录