OpenHarmony开发者论坛

标题: 编译libdisplay_gfx.z.so,该库依赖闭源库xxx.so, 但是libdisplay_gfx.z.so的NEEDED字段包含了xxx.so的路径信息,该如何配置gn脚本把这个路径信息去掉? [打印本页]

作者: 海天一色    时间: 2024-10-9 16:03
标题: 编译libdisplay_gfx.z.so,该库依赖闭源库xxx.so, 但是libdisplay_gfx.z.so的NEEDED字段包含了xxx.so的路径信息,该如何配置gn脚本把这个路径信息去掉?
如题,readelf -d libdisplay_gfx.z.so,期望的结果是

(NEEDED)             共享库:[xxx.so]

但是实际结果是:

(NEEDED)             共享库:[obj/device/soc/xxx/xxxx/hardware/xxxx/lib64/xxx.so]


使用的是4.1-release版本

作者: fengyunrenwu    时间: 2024-10-12 14:53
正常链接动态库带路径和rpath是正常的,如果想不带路径,需要重新编译被依赖的共享库,指定该共享库的library,不存在library name。
作者: 海天一色    时间: 2024-10-14 11:14
我直接用ldflags来指定依赖的共享库就没问题了
ohos_shared_library("libdisplay_buffer_vdi_impl") {
  sources = [
     "src/display_gralloc/display_buffer_vdi_impl.cpp",
     "src/display_gralloc/display_gralloc_gbm.cpp"
  ]
  
  include_dirs = [
    "./src/display_gralloc",
    "//drivers/peripheral/base",
    "//drivers/interface/display/composer/hdifd_parcelable",
    "//drivers/interface/display/buffer",
    "//drivers/peripheral/display/utils/include",
    "//drivers/peripheral/display/buffer/hdi_service/include",
  ]

  output_name = "libdisplay_buffer_vdi_impl"
  cflags = ["-Wno-macro-redefined"]
  #deps = [ "//device/soc/xxxx/xxxx/hardware/xxx:libxxx" ]   #原来写法
  ldflags = [ "-L../../device/soc/xxx/edge10/hardware/xxx/lib64", "-lxxx" ]   #修改后写法

  external_deps = [
    "c_utils:utils",
    "drivers_interface_display:display_buffer_idl_headers",
    "drivers_interface_display:display_composer_idl_headers",
    "hdf_core:libhdf_utils",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]

  install_enable = true
  install_images = [ chipset_base_dir ]
  subsystem_name = "xxxx"
  part_name = "xxx"
}




欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5