建立应用程序的过程官网教程说的十分清楚了,本次就跟着体验一番。
https://device.harmonyos.com/cn/docs/documentation/guide/quickstart-lite-steps-hi3518-application-framework-0000001105528572
新建applications/sample/camera/apps/src/helloworld.c目录及文件,代码如下所示
- #include <stdio.h>
- int main(int argc, char **argv)
- {
- printf("n************************************************n");
- printf("nttHello OHOS!n");
- printf("n************************************************nn");
- return 0;
- }
复制代码
新建applications/sample/camera/apps/BUILD.gn文件,内容如下所示:
- import("//build/lite/config/component/lite_component.gni")
- lite_component("hello-OHOS") {
- features = [ ":helloworld" ]
- }
- executable("helloworld") {
- output_name = "helloworld"
- sources = [ "src/helloworld.c" ]
- include_dirs = []
- defines = []
- cflags_c = []
- ldflags = []
- }
复制代码修改文件build/lite/components/applications.json,添加组件hello_world_app的配置
- {
- "components": [
- {
- "component": "camera_sample_communication",
- "description": "Communication related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/communication"
- ],
- "targets": [
- "//applications/sample/camera/communication:sample"
- ],
- "rom": "",
- "ram": "",
- "output": [],
- "adapted_kernel": [ "liteos_a" ],
- "features": [],
- "deps": {
- "components": [],
- "third_party": []
- }
- },
- {
- "component": "hello_world_app",
- "description": "Communication related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/apps"
- ],
- "targets": [
- "//applications/sample/camera/apps:hello-OHOS"
- ],
- "rom": "",
- "ram": "",
- "output": [],
- "adapted_kernel": [ "liteos_a" ],
- "features": [],
- "deps": {
- "components": [],
- "third_party": []
- }
- },
- {
- "component": "camera_sample_app",
- "description": "Camera related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/launcher",
- "applications/sample/camera/cameraApp",
- "applications/sample/camera/setting",
- "applications/sample/camera/gallery",
- "applications/sample/camera/media"
- ],
复制代码修改文件vendor/hisilicon/hispark_aries/config.json,新增hello_world_app组件的条目
- {
- "subsystem": "applications",
- "components": [
- { "component": "hello_world_app", "features":[] }
- ]
- },
复制代码编译、烧录后,在bin目录下可以看到应用程序了,运行效果: