Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b77f17e0
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b77f17e0
编写于
3月 28, 2022
作者:
D
duangavin123
提交者:
Gitee
3月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md.
Signed-off-by:
N
duangavin123
<
duanxichao@huawei.com
>
上级
f4256442
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
39 deletion
+55
-39
zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md
.../quick-start/quickstart-standard-running-rk3568-create.md
+55
-39
未找到文件。
zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md
浏览文件 @
b77f17e0
#
创建应用程序<a name="ZH-CN_TOPIC_0000001234205905
"></a>
#
编写“Hello World”程序<a name="ZH-CN_TOPIC_0000001260983173
"></a>
下方将
通过修改源码的方式
展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
这里演示新建examples子系统,添加hello部件以及该部件下的helloworld模块。
## 示例目录<a name="section1731810561374"></a>
示例完整目录如下。
示例完整目录如下。
```
```
applications/standard/hello
applications/sample/hello
├── helloworld
│ │── BUILD.gn
│ ├── BUILD.gn
│ │── include
│ ├── include
│ │ └── helloworld.h
│ │ └── helloworld.h
│
└
── src
│
│
── src
│
└── helloworld.c
│
│
└── helloworld.c
├── ohos.build
│ └── bundle.json
build
build
├
── subsystem_config.json
└
── subsystem_config.json
productdefine/common
productdefine/common
└── products
└── products
└── rk3568.json
└── rk3568.json
```
```
下方为新建应用程序步骤,请在
[
获取源码
](
quickstart-standard-sourcecode-acquire.md
)
章节下载的源码目录中进行下述操作:
## 开发步骤<a name="section6771191495218"></a>
1.
新建目录及源码。
请在源码目录中通过以下步骤创建“Hello World”应用程序:
新建applications/standard/hello/helloworld/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
1.
创建目录,编写业务代码。
新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
```
```
#include <stdio.h>
#include <stdio.h>
...
@@ -46,7 +47,7 @@ productdefine/common
...
@@ -46,7 +47,7 @@ productdefine/common
}
}
```
```
再添加头文件applications/s
tandard/hello/helloworld
/include/helloworld.h,代码如下所示。
再添加头文件applications/s
ample/hello
/include/helloworld.h,代码如下所示。
```
```
#ifndef HELLOWORLD_H
#ifndef HELLOWORLD_H
...
@@ -68,7 +69,7 @@ productdefine/common
...
@@ -68,7 +69,7 @@ productdefine/common
```
```
2.
新建编译组织文件。
2.
新建编译组织文件。
1.
新建applications/s
tandard/hello/helloworld
/BUILD.gn文件,内容如下所示:
1.
新建applications/s
ample/hello
/BUILD.gn文件,内容如下所示:
```
```
import("//build/ohos.gni") # 导入编译模板
import("//build/ohos.gni") # 导入编译模板
...
@@ -85,44 +86,59 @@ productdefine/common
...
@@ -85,44 +86,59 @@ productdefine/common
ldflags = []
ldflags = []
configs = []
configs = []
deps =[] # 部件内部依赖
deps =[] # 部件内部依赖
part_name = "hello" # 所属部件名称,必选
part_name = "hello" # 所属部件名称,必选
install_enable = true # 是否默认安装(缺省默认不安装),可选
install_enable = true # 是否默认安装(缺省默认不安装),可选
}
}
```
```
2. 新建applications/s
tandard/hello/ohos.build文件,添加hello
部件描述,内容如下所示。
2. 新建applications/s
ample/hello/bundle.json文件,添加sample
部件描述,内容如下所示。
```
```
{
{
"subsystem": "examples",
"name": "@ohos/hello",
"parts": {
"description": "Hello world example.",
"hello": {
"version": "3.1",
"version": "1.0.0",
"license": "Apache License 2.0",
"variants": [
"publishAs": "code-segment",
"wearable",
"segment": {
"phone"
"destPath": "applications/sample/hello"
],
},
"module_list": [
"dirs": {},
"//applications/standard/hello:helloworld"
"scripts": {},
],
"component": {
"inner_kits": [],
"name": "hello",
"test_list": []
"subsystem": "sample",
"syscap": [],
"features": [],
"adapted_system_type": [ "mini", "small", "standard" ],
"rom": "10KB",
"ram": "10KB",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//applications/sample/hello:helloworld"
],
"inner_kits": [],
"test": []
}
}
}
}
}
}
```
```
ohos.build文件包含两个部分,第一部分subsystem说明该子系统的名称,parts定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module\_list,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test\_list中说明,inner\_kits与test\_li
st没有也可以不添加。
bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub\_component,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test中说明,inner\_kits与te
st没有也可以不添加。
3.
修改子系统配置文件。
3.
修改子系统配置文件。
在build/subsystem_config.json中添加examples子系统配置。
在build/subsystem\_config.json中添加新建的子系统的配置。
```
```
"
examples
": {
"
sample
": {
"path": "applications/standard
/hello",
"path": "applications/sample
/hello",
"name": "examples
"
"name": "sample
"
},
},
```
```
4.
修改产品配置文件。
4.
修改产品配置文件。
...
@@ -132,7 +148,7 @@ productdefine/common
...
@@ -132,7 +148,7 @@ productdefine/common
```
```
"usb:usb_manager_native":{},
"usb:usb_manager_native":{},
"applications:prebuilt_hap":{},
"applications:prebuilt_hap":{},
"
examples
:hello":{},
"
sample
:hello":{},
"wpa_supplicant-2.9:wpa_supplicant-2.9":{},
"wpa_supplicant-2.9:wpa_supplicant-2.9":{},
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录