編寫“Hello World”程序
下方將展示如何在單板上運(yùn)行第一個(gè)應(yīng)用程序,其中包括新建應(yīng)用程序、編譯、燒寫、運(yùn)行等步驟,最終輸出“Hello World!”。
示例目錄
示例完整目錄如下:
applications/sample/hello
│── BUILD.gn
└── src
└── helloworld.c
`HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿`
開發(fā)步驟
請(qǐng)?jiān)谠创a目錄中通過以下步驟創(chuàng)建“Hello World”應(yīng)用程序。
- 新建目錄及源碼。
新建applications/sample/hello/src/helloworld.c目錄及文件,代碼如下所示,用戶可以自定義修改打印內(nèi)容(例如:修改OHOS為World)。當(dāng)前應(yīng)用程序可支持標(biāo)準(zhǔn)C及C++的代碼開發(fā)。#include < stdio.h > int main(int argc, char **argv) { printf("nn"); printf("nttHello OHOS!n"); printf("nnn"); return 0; }
- 新建編譯組織文件。
新建applications/sample/hello/BUILD.gn文件,內(nèi)容如下所示:import("http://build/lite/config/component/lite_component.gni") lite_component("hello-OHOS") { features = [ ":helloworld" ] } executable("helloworld") { output_name = "helloworld" sources = [ "src/helloworld.c" ] }
- 添加新組件。
修改文件build/lite/components/communication.json,添加組件hello_world_app的配置,如下所示為communication.json文件片段,"##start##"和"##end##"之間為新增配置("##start##"和"##end##"僅用來標(biāo)識(shí)位置,添加完配置后刪除這兩行):{ "components": [ { "component": "camera_sample_communication", "description": "Communication related samples.", "optional": "true", "dirs": [ "applications/sample/camera/communication" ], "targets": [ "http://applications/sample/camera/communication:sample" ], "rom": "", "ram": "", "output": [], "adapted_kernel": [ "liteos_a" ], "features": [], "deps": { "components": [], "third_party": [] } }, ##start## { "component": "hello_world_app", "description": "hello world samples.", "optional": "true", "dirs": [ "applications/sample/hello" ], "targets": [ "http://applications/sample/hello:hello-OHOS" ], "rom": "", "ram": "", "output": [], "adapted_kernel": [ "liteos_a" ], "features": [], "deps": { "components": [], "third_party": [] } }, ##end## { "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" ],
鴻蒙開發(fā)指導(dǎo)文檔:[qr23.cn/FBD4cY
]
- 修改單板配置文件。
修改文件vendor/hisilicon/hispark_taurus/config.json,新增hello_world_app組件的條目,如下所示代碼片段為applications子系統(tǒng)配置,"##start##"和"##end##"之間為新增條目("##start##"和"##end##"僅用來標(biāo)識(shí)位置,添加完配置后刪除這兩行):{ "subsystem": "applications", "components": [ { "component": "camera_sample_app", "features":[] }, { "component": "camera_sample_ai", "features":[] }, ##start## { "component": "hello_world_app", "features":[] }, ##end## { "component": "camera_screensaver_app", "features":[] } ] },
審核編輯 黃宇
-
開發(fā)板
+關(guān)注
關(guān)注
25文章
5682瀏覽量
104817 -
鴻蒙
+關(guān)注
關(guān)注
60文章
2620瀏覽量
44063 -
OpenHarmony
+關(guān)注
關(guān)注
29文章
3854瀏覽量
18626 -
RK3568
+關(guān)注
關(guān)注
5文章
584瀏覽量
6422
發(fā)布評(píng)論請(qǐng)先 登錄
鴻蒙OpenHarmony【標(biāo)準(zhǔn)系統(tǒng)編寫“Hello World”程序】 (基于RK3568開發(fā)板)

鴻蒙OpenHarmony【標(biāo)準(zhǔn)系統(tǒng)編譯】 (基于RK3568開發(fā)板)

北京迅為RK3568開發(fā)板OpenHarmony系統(tǒng)南向驅(qū)動(dòng)開發(fā)內(nèi)核HDF驅(qū)動(dòng)框架架構(gòu)

鴻蒙OpenHarmony南向/北向快速開發(fā)教程-迅為RK3568開發(fā)板
RK3568開發(fā)板鴻蒙OpenHarmony系統(tǒng)固件燒寫步驟
迅為RK3568開發(fā)板鴻蒙OpenHarmony系統(tǒng)固件燒寫步驟
如何在RK3568開發(fā)板上面運(yùn)行OpenHarmony標(biāo)準(zhǔn)系統(tǒng)
標(biāo)準(zhǔn)系統(tǒng):DAYU200開發(fā)套件(RK3568)
標(biāo)準(zhǔn)系統(tǒng):KHDVK-3568A智慧屏開發(fā)套件(RK3568)
RK3568開發(fā)板上絲滑體驗(yàn)OpenHarmony標(biāo)準(zhǔn)系統(tǒng)

OpenHarmony:如何使用HDF平臺(tái)驅(qū)動(dòng)控制PWM

OpenHarmony:全流程講解如何編寫RTC平臺(tái)驅(qū)動(dòng)以及應(yīng)用程序

瑞芯微RK3568鴻蒙開發(fā)板OpenHarmony系統(tǒng)修改cfg文件權(quán)限方法

【北京迅為】iTOP-RK3568開發(fā)板鴻蒙OpenHarmony系統(tǒng)南向驅(qū)動(dòng)開發(fā)實(shí)操-HDF驅(qū)動(dòng)配置UART

評(píng)論