讨论广场 问答详情
OH6 编译依赖库问题,编译不过 找不到基础库 : 帮看看 build.gn 该如何写
ljp9405312 2026-02-26 17:42:47
84 评论 分享


[OHOS ERROR] [GN] ERROR at //vendor/hihope/dayu300/bluetooth/BUILD.gn:73:5: OHOS component : (//base/hiviewdfx/hilog/interfaces/native/innerkits) not found.

[OHOS ERROR] [GN]     "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog"

[OHOS ERROR] [GN]     ^------------------------------------------------------------

[OHOS ERROR] [GN] See //build/templates/cxx/cxx.gni:972:3: whence it was called.

[OHOS ERROR] [GN]   shared_library("${target_name}") {

build.gn 如下写的依赖:
  external_deps = [
    "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog"  
  ]    

这个目标是存在的啊,为啥编译报告上面找不到 呢
ing@113ser:~/work/oh6/dayu300_0210$ ls  base/hiviewdfx/hilog/interfaces/native/innerkits/ -l
total 24
-rw-rw-r-- 1 ing ping 5402 2月  10 20:40 BUILD.gn
drwxrwxr-x 4 ing ing 4096 2月  10 20:40 include
-rw-rw-r-- 1 ing ing 8497 2月  10 20:40 libhilog.map
其中BUIlD.gn 有如下:

template("libhilog") {
  forward_variables_from(invoker, "*")
  if (current_os == "android" || current_os == "ios") {
    ohos_static_library(target_name) {
      public_configs = [ ":libhilog_pub_config" ]
      deps = [ "../../../platform:libhilog_platform_source_$platform" ]

      part_name = "hilog"
      subsystem_name = "hiviewdfx"
    }
  } else {
    ohos_shared_library(target_name) {
      branch_protector_ret = "pac_ret"
      sanitize = {
        cfi = true
        cfi_cross_dso = true
        debug = false
      }
      public_configs = [ ":libhilog_pub_config" ]
      deps = [ "../../../frameworks/libhilog:libhilog_source_$platform" ]
      if (platform == "ohos") {
        output_extension = "so"
        version_script = "libhilog.map"
      }

      install_enable = !hilog_native_feature_ohcore
      install_images = [
        "system",
        "updater",
      ]

      if (platform == "ohos") {
        innerapi_tags = [
          "chipsetsdk",
          "platformsdk",
          "sasdk",
        ]
      }

      part_name = "hilog"
      subsystem_name = "hiviewdfx"
    }
  }
}

84 评论 分享
写回答
全部评论(4)

build.gn改成external_deps=["hilog:libhilog"]
bundle.json里components里添加"hilog"

2026-02-26 19:18:07
引用:“我发现 vendor/hihope/rk3568 这个工程是可以编译过的, 它的build.gn external_deps = [ "c_utils:utils", "hilog:libhilog", ] 这样可以过,也就是主要还是工程配置 bundle.json里components里添加"hilog" 这个是那个 bundle.js”
现在vendor下面的能编译过是因为添加了白名单
2026-02-27 09:45:08
引用:“我发现 vendor/hihope/rk3568 这个工程是可以编译过的, 它的build.gn external_deps = [ "c_utils:utils", "hilog:libhilog", ] 这样可以过,也就是主要还是工程配置 bundle.json里components里添加"hilog" 这个是那个 bundle.js”
vendor下面用的是ohos.build进行编译的,那个不规范,规范的应该是用bundle.josn进行编译的,不知道为什么官方不去修改
2026-02-27 09:44:42
2026-02-26 19:27:21
我发现 vendor/hihope/rk3568 这个工程是可以编译过的, 它的build.gn external_deps = [ "c_utils:utils", "hilog:libhilog", ] 这样可以过,也就是主要还是工程配置 bundle.json里components里添加"hilog" 这个是那个 bundle.json 呢 /vendor/hihope/rk3568/bluetooth/build.gn 但是 /vendor/hihope/rk3568/ 都没有 bundle.json 啊
2026-02-26 19:27:21