Skip to content

xmake require --export 无法导出完整的库文件 #6997

@bigbigrain

Description

@bigbigrain

Xmake 版本

3.0.1

操作系统版本和架构

Fedora Linux 42, Linux 6.16.12-200.fc42.x86_64

描述问题

直接使用 xmake i 命令无法同步打包三方库中的 动态库
尝试使用 xmake require --export <libname> 命令导出时仅导出被导出的依赖库,但是没有导出库本身。

> xmake require --export --packagedir=./install librdkafka
exporting ninja-1.12.1 [host, from:cmake]
  -> ./install/n/ninja/latest/725e51fe81b74141ade9efbd3ccaf900
exporting cmake-3.31.6 [host, from:librdkafka,libcurl]
  -> ./install/c/cmake/latest/725e51fe81b74141ade9efbd3ccaf900
exporting libcurl-8.14.1 [toolchains:"LLVM-21", from:librdkafka]
  -> ./install/l/libcurl/8.14.1/5c480ea6262e44b8bd99d359d3bb6013
exporting openssl3-3.6.0 [toolchains:"LLVM-21", from:librdkafka, license:Apache-2.0]
  -> ./install/o/openssl3/3.6.0/bc7463caf64941abb5cbf63f82bc5a83
> tree install -L 2
install
├── c
│   └── cmake
├── l
│   └── libcurl
├── n
│   └── ninja
└── o
    └── openssl3

9 directories, 0 files

这里看到动态库编译的 librdkafka 没有被导出, 但是 静态库 编译的依赖 openssl 和 libcurl 的目录被创建了。

期待的结果

  1. 工程内部脚本域 on_install(function (target)) 中,如果通过 target 对象获取到自身 deps() 的 package 的 安装路径? 以允许我通过 os.cp() 在安装时复制动态库。
  2. 亦或者,是我使用 xmake require --export 存在问题?

工程配置

工程本体(部分)

add_requires("librdkafka", {
    system = false,
    configs = {
        shared = true,
        ssl = true  -- 连接本地包中的 openssl3
    },
    debug = false
})

target("capture", function()
    add_packages(
        "boost",
        "librdkafka", -- 其他库不列出
        { public = true }
    )
end)

### 附加信息和错误日志

一次xmake f 生成了两个 rdkafka 路径,但是工程内部仅仅 `add_deps` `add_requires` 了一次 librdkafka```console
ll /home/nmpassthf/.xmake/packages/l/librdkafka/2.12.1/5212c166342b43488a191aba8349bfd6/lib
total 13M
drwxr-xr-x 1 nmpassthf nmpassthf   14 Nov  5 15:03 cmake/
lrwxrwxrwx 1 nmpassthf nmpassthf   17 Nov  5 15:03 librdkafka++.so -> librdkafka++.so.1*
lrwxrwxrwx 1 nmpassthf nmpassthf   15 Nov  5 15:03 librdkafka.so -> librdkafka.so.1*
-rwxr-xr-x 1 nmpassthf nmpassthf 204K Nov  5 15:03 librdkafka++.so.1*
-rwxr-xr-x 1 nmpassthf nmpassthf  12M Nov  5 15:03 librdkafka.so.1*
drwxr-xr-x 1 nmpassthf nmpassthf   44 Nov  5 15:03 pkgconfig/
ll /home/nmpassthf/.xmake/packages/l/librdkafka/2.12.1/5212c166342b43488a191aba8349bfd6/
total 8.0K
drwxr-xr-x 1 nmpassthf nmpassthf   20 Nov  5 15:03 include/
drwxr-xr-x 1 nmpassthf nmpassthf  148 Nov  5 15:03 lib/
-rw-r--r-- 1 nmpassthf nmpassthf 1.3K Nov  5 15:03 manifest.txt
-rw-r--r-- 1 nmpassthf nmpassthf   56 Nov  5 15:03 references.txt
drwxr-xr-x 1 nmpassthf nmpassthf   16 Nov  5 15:03 share/
ll /home/nmpassthf/.xmake/packages/l/librdkafka/2.12.1/81642a055b4540d1823df1dec27d8a08/
total 0

背景信息

工程内部使用 离线的 xmake (xmake g --network=private),使用 package() 功能描述并安装三方库,package 包的 lua 部分主要参考了 xrepo, 但是包的源码使用 file:// 协议从本地拉取。
其中,cmake 等系统工具使用如下描述:

package("cmake")
  set_kind("binary")
  add_extsources("dnf::cmake")

其余普通 package 与 xrepo 中区别不大。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions