偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

OpenHarmony 如何使用閉源動(dòng)態(tài)庫

開發(fā) 后端
有的公司不想自己的算法被開源出去,只提供了開發(fā)庫,該文檔演示如何使用別人閉源的動(dòng)態(tài)庫流程。C/C++動(dòng)態(tài)庫的使用。

[[442567]]

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

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

https://harmonyos.51cto.com

簡介

有的公司不想自己的算法被開源出去,只提供了開發(fā)庫,該文檔演示如何使用別人閉源的動(dòng)態(tài)庫流程。

C/C++動(dòng)態(tài)庫的使用。

閉源動(dòng)態(tài)庫

  • 編譯之后的名稱:libmoduleb_lib.z.so
  • 動(dòng)態(tài)庫路徑:test\example\partB\dll_use\dll
  • 編譯配置:test\example\partB\dll_use\dll\BUILD.gn
  1. import("//build/ohos.gni"
  2.  
  3. # 全量完整編譯會(huì)把庫copy到如下路徑 
  4. out/ohos-arm-release/packages/phone/system/lib/libmoduleb_lib.z.so  
  5. ohos_prebuilt_shared_library("dll_module_lib") { 
  6.   source = "./libmoduleb_lib.z.so" 
  7.   install_enable = true 
  8.   subsystem_name = "sub_example" 
  9.   part_name = "partB" 
  10. group("dll") { 
  11.   deps = [ 
  12.     ":dll_module_lib" 
  13.   ] 

調(diào)用動(dòng)態(tài)庫的可執(zhí)行文件

  • 編譯后可執(zhí)行文件:out\ohos-arm-release\sub_example\partB\dll_use
  • 編譯配置路徑: test\example\partB\dll_use\BUILD.gn
  1. import("//build/ohos.gni"
  2.  
  3. config("dll_use_config") { 
  4.   include_dirs = [  
  5.     "include"
  6.     "dll/include" 
  7.   ] 
  8.  
  9. ohos_executable("dll_use") { 
  10.   sources = [ 
  11.     "//test/example/partB/dll_use/src/dll_use.c"
  12.     "//test/example/partB/dll_use/src/main.c" 
  13.   ] 
  14.   public_configs = [ ":dll_use_config" ] 
  15.   deps = [ ] 
  16.   # 依賴動(dòng)態(tài)庫 
  17.   external_deps = [ "partB:dll", ] 
  18.   part_name = "partB" 
  19.   subsystem_name = "sub_example" 

 ohos.build添加的內(nèi)容

  1.     "subsystem""sub_example"
  2.     "parts": { 
  3.         "partB": { 
  4.             "module_list": [ 
  5.                 ... 
  6.                 "//test/example/partB/dll_use/dll:dll"
  7.                 "//test/example/partB/dll_use:dll_use"
  8.                 ... 
  9.             ], 
  10.             "inner_kits": [ 
  11.                 ... 
  12.                 { 
  13.                     "type""so"
  14.                     "name""//test/example/partB/dll_use/dll:dll"
  15.                     "header": { 
  16.                         "header_files": [ 
  17.                             "moduleB.h" 
  18.                         ], 
  19.                         "header_base""//test/example/partB/dll_use/dll/include" 
  20.                     } 
  21.                 } 
  22.                 ... 
  23.             ] 
  24.         }, 
  25.     ... 

編譯

閉源動(dòng)態(tài)鏈接庫的編譯命令:

  1. ./build.sh --product-name Hi3516DV300 --ccache --build-target dll_module_lib 

 調(diào)用動(dòng)態(tài)庫可執(zhí)行文件編譯命令:

  1. ./build.sh --product-name Hi3516DV300 --ccache --build-target dll_use 

測試運(yùn)行

編譯成功后,可以把編譯好的 可執(zhí)行文件和 閉源動(dòng)態(tài)庫用hdc_std.exe發(fā)送到Hi3516DV300開發(fā)板中去運(yùn)行,在串口終端上運(yùn)行可執(zhí)行文件,查看調(diào)用情況。如果變量編譯燒寫系統(tǒng),就不用使用hdc_std.exe發(fā)送文件了。

動(dòng)態(tài)庫libmoduleb_lib.z.so放入開發(fā)板的/system/lib目錄下:

  1. hdc_std.exe file send Z:\test\example\partB\dll_use\dll\libmoduleb_lib.z.so /data/test 

 dll_use放入開發(fā)板本人自建/data/test目錄下:

  1. hdc_std.exe file send Z:\out\ohos-arm-release\sub_example\partB\dll_use /data/test 

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

  1. chmod 0711 /data/test/dll_use 

 運(yùn)行單元測試用例:

  1. /data/test/dll_use 
#星光計(jì)劃2.0# OpenHarmony 如何使用閉源動(dòng)態(tài)庫-鴻蒙HarmonyOS技術(shù)社區(qū)

藍(lán)色部分為動(dòng)態(tài)庫中的輸出。

注意:動(dòng)態(tài)庫與系統(tǒng)的兼容性,因?yàn)槲臋n中的動(dòng)態(tài)庫是筆者自己之前在同一個(gè)系統(tǒng)編譯出來的,所以沒出現(xiàn)其他問題。

文檔里面設(shè)計(jì)到內(nèi)容的沒有完全展示,想查看源碼內(nèi)容可以下載:

【源代碼】,重點(diǎn)關(guān)注example\partB\dll_use目錄

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

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

https://harmonyos.51cto.com

 

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

2021-12-27 10:21:18

鴻蒙HarmonyOS應(yīng)用

2021-03-08 16:08:21

AIOps工具開源

2013-11-19 11:55:14

2012-12-10 14:09:32

Linux開源

2018-07-13 09:55:35

Eureka閉源Spring Clou

2011-06-08 10:29:37

開源閉源蘋果

2014-08-22 11:15:52

2018-04-23 16:46:59

開源

2011-06-08 09:15:16

閉源iOS蘋果

2012-12-11 10:08:48

Linux開源開源代碼

2010-08-24 09:25:15

Oracle

2016-12-01 18:52:42

開源閉源

2017-04-20 13:33:12

代碼開源PySonar

2022-10-21 08:17:06

開源項(xiàng)目閉源

2022-08-23 16:27:29

OpenCV人臉識別

2011-03-16 17:26:22

動(dòng)態(tài)數(shù)據(jù)庫

2023-09-14 15:49:42

PWM鴻蒙

2023-09-06 15:35:14

2020-05-07 18:39:15

數(shù)據(jù)庫閉源開源

2011-07-13 15:32:38

ODBC數(shù)據(jù)庫驅(qū)動(dòng)程序系統(tǒng)DSN
點(diǎn)贊
收藏

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