自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Openharmony 設(shè)備開發(fā)之helloworld (L2)

系統(tǒng) OpenHarmony
本篇分別從介紹子系統(tǒng)添加,介紹靜態(tài)庫編譯,介紹動態(tài)庫編譯,介紹動態(tài)庫和靜態(tài)庫的調(diào)用四個方面入門了解設(shè)備開發(fā)。

??想了解更多內(nèi)容,請訪問:??

??51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)??

??https://harmonyos.51cto.com??

一、簡介

  1. 介紹子系統(tǒng)添加
  2. 介紹靜態(tài)庫編譯
  3. 介紹動態(tài)庫編譯
  4. 介紹動態(tài)庫和靜態(tài)庫的調(diào)用

入門了解設(shè)備開發(fā):

partA/feature1編譯的靜態(tài)庫,

partB/module編譯的是動態(tài)庫

partA/feature2可執(zhí)行程序中調(diào)用動態(tài)庫和靜態(tài)庫

二、代碼添加編譯

2.1 子系統(tǒng)添加

配置文件:build/subsystem_config.json

,
"sub_example": {
"project": "hmf/test",
"path": "test/example",
"name": "sub_example",
"dir": "test"
}

如果自己想自定義目錄,test為測試代碼放在目錄路徑。

2.2 子模塊添加

配置文件:productdefine/common/products/Hi3516DV300.json

{
"product_name": "Hi3516DV300",
"product_company": "hisilicon",
"product_device": "hi3516dv300",
"version": "2.0",
"type": "standard",
"product_build_path": "device/hisilicon/build",
"parts":{

"sub_example:partB":{},
"sub_example:partA":{}
}
}

2.3 模塊partA/feature1

目錄結(jié)構(gòu)

編譯配置文件:test\example\partA\feature1\BUILD.gn

import("http://build/ohos.gni")

config("helloworld1_lib_config") {
include_dirs = [ "include" ]
}
ohos_static_library("libhelloworl1_lib") {
output_extension = "a"
sources = [
"include/helloworld1.h",
"src/helloworld1.c"
]
public_configs = [ ":helloworld1_lib_config" ]
part_name = "partA"
}

其中ohos_static_library標(biāo)準(zhǔn)系統(tǒng)是ninja生成靜態(tài)庫的關(guān)鍵。

2.4 模塊partB/module

目錄結(jié)構(gòu)

配置文件test\example\partB\module\BUILD.gn

import("http://build/ohos.gni")

config("module_lib_config") {
include_dirs = [ "include" ]
}

ohos_shared_library("module_lib") {
sources = [
"http://test/example/partB/module/include/module.h",
"http://test/example/partB/module/src/module.c"
]
public_configs = [ ":module_lib_config" ]
part_name = "partB"
subsystem_name = "sub_example"
}

其中ohos_shared_library標(biāo)準(zhǔn)系統(tǒng)是ninja生成動態(tài)庫的關(guān)鍵。

2.5 動態(tài)庫和靜態(tài)庫調(diào)用模塊partA/feature2

目錄結(jié)構(gòu)

編譯配置:test\example\partA\feature2\BUILD.gn

import("http://build/ohos.gni")

ohos_executable("helloworld2_bin") {
sources = [
"src/helloworld2.c"
]
include_dirs = [
"include",
"http://test/example/partB/module/include"
]
deps = [ # 組件內(nèi)模塊依賴
"../feature1:libhelloworl1_lib",
#"http://test/example/partB/module:module_lib",
"../feature3:feature3_etc",
]
external_deps = [ "partB:module_lib", ] # 跨組件的依賴,格式為“組件名:模塊名”
install_enable = true # 可執(zhí)行程序缺省不安裝,需要安裝時需要指定
part_name = "partA"
subsystem_name = "sub_example"
}

調(diào)用的C代碼:test\example\partA\feature2\src\helloworld2.c

#include "helloworld1.h" // 模塊partA/feature1
#include "module.h" // 模塊partB/module
#include <stdio.h>

void helloworld2(void)
{
printf("[demo] hello world 2222\n");
helloworld1(); // partA/feature1
module(); // partB/module
}

int main()
{
helloworld2();
return 0;
}

2.6 編譯配置test\example\ohos.build

配置中的inner_kits是test\example\partA\feature2\BUILD.gn跨組件依賴配置的關(guān)鍵。

{
"subsystem": "sub_example",
"parts": {
"partB": {
"module_list": [
"http://test/example/partB/module:module_lib"
],
"inner_kits": [
{
"type": "so",
"name": "http://test/example/partB/module:module_lib",
"header": {
"header_files": [
"module.h"
],
"header_base": "http://test/example/partB/module/include"
}
}
],
"system_kits": [],
"test_list": []
},
"partA": {
"module_list": [
"http://test/example/partA/feature1:libhelloworl1_lib",
"http://test/example/partA/feature2:helloworld2_bin"
],
"inner_kits": [],
"system_kits": [],
"test_list": []
}
}
}

三、編譯測試運(yùn)行

3.1 編譯:

./build.sh --product-name Hi3516DV300 --ccache --build-target helloworld2_bin

編譯成功后,可以把編譯好的helloworld2_bin和libmodule_lib.z.so用hdc_std.exe發(fā)送到Hi3516DV300開發(fā)板中去運(yùn)行,在串口終端上輸出調(diào)用結(jié)果。

3.2 修改系統(tǒng)權(quán)限,目錄能讀能寫:

mount -o remount,rw /

3.3 發(fā)送文件到開發(fā)板:

hdc_std.exe file send Z:\L2\out\ohos-arm-release\sub_example\partB\libmodule_lib.z.so /system/lib
//開發(fā)板目錄/data/test為自建目錄,沒有的話,先創(chuàng)建。
hdc_std.exe file send Z:\L2\out\ohos-arm-release\sub_example\partA\helloworld2_bin /data/test

3.3 修改成可執(zhí)行權(quán)后:

chmod 0711 /data/test/helloworld2_bin

3.4 運(yùn)行:

/data/test/helloworld2_bin

 

文檔中的代碼沒有完全展示,下載??【源代碼】??

重點關(guān)注目錄:example\partB\module,example\partA\feature1,example\partA\feature2

代碼庫中的源碼相對于文檔中的代碼有少許調(diào)整,基本結(jié)構(gòu)不變.

??想了解更多內(nèi)容,請訪問:??

??51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)??

??https://harmonyos.51cto.com??

責(zé)任編輯:jianghua 來源: 鴻蒙社區(qū)
相關(guān)推薦

2022-02-17 16:47:40

OpenharmonIPC通信鴻蒙

2022-06-22 09:14:23

事件打點HiSysEvent

2022-02-15 14:06:36

OpenHarmon操作系統(tǒng)鴻蒙

2022-07-04 16:41:16

IPC通信HiTrace

2022-07-14 19:03:33

IPC服務(wù)鴻蒙

2022-04-06 11:27:05

harmonyeTS 開發(fā)NAPI開發(fā)

2022-02-17 17:52:00

openharmon項目開發(fā)鴻蒙

2014-07-30 16:43:49

Android

2021-10-20 19:14:30

緩存CacheCPU

2022-09-07 15:35:49

設(shè)備開發(fā)鴻蒙

2022-03-21 15:42:36

智能家居物聯(lián)網(wǎng)MQTT

2015-01-20 13:19:52

OpenStack網(wǎng)絡(luò)層數(shù)據(jù)鏈路層

2022-07-29 14:29:24

設(shè)備開發(fā)鴻蒙

2022-01-06 16:16:21

鴻蒙HarmonyOS應(yīng)用

2022-10-24 14:54:29

LWIP協(xié)議鴻蒙

2022-06-14 15:07:04

IPC客戶端服務(wù)端

2022-02-14 13:52:04

OpenHarmor系統(tǒng)鴻蒙

2020-11-10 11:58:17

鴻蒙應(yīng)用開發(fā)

2023-01-31 09:12:16

CPU芯片緩存

2023-02-20 08:00:00

點贊
收藏

51CTO技術(shù)棧公眾號