You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

交叉编译BlueZ遇glib难题:如何编译无桌面功能的glib?

[278/705] Linking target gio/gio-launch-desktop
FAILED: gio/gio-launch-desktop
gio-launch-desktop.c:199:(.text.startup+0x58): undefined
reference to _g_fd_is_journal' collect2: error: ld returned 1 exit status ... [285/705] Linking target glib/gtester FAILED: glib/gtester /gmessages.c:2117:(.text+0x6a98): undefined reference to _g_fd_is_journal'
collect2: error: ld returned 1 exit status
...
[286/705] Linking target gobject/gobject-query
FAILED: gobject/gobject-query
gmessages.c:2117:(.text+0x6818): undefined reference to `_g_fd_is_journal'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

## 解决方案
完全可以编译仅包含CLI所需功能的glib,通过调整Meson配置参数禁用桌面相关模块和不必要的依赖,即可解决当前链接错误:

### 调整后的Meson配置命令(按需选择)
#### 方案1:完全禁用GIO及桌面功能(若BlueZ无需GIO)
```bash
meson setup ~/src/lib/glib . \
  --cross-file ./cross.txt \
  --prefix=staging \
  --default-library=static \
  -Dintrospection=disabled \
  -Dtests=false \
  -Dgio=false \
  -Ddesktop-utils=false \
  -Djournald=false

方案2:保留GIO核心功能,仅禁用桌面及journald支持(若BlueZ需要GIO)

meson setup ~/src/lib/glib . \
  --cross-file ./cross.txt \
  --prefix=staging \
  --default-library=static \
  -Dintrospection=disabled \
  -Dtests=false \
  -Ddesktop-utils=false \
  -Djournald=false \
  -Dgio-modules=none

参数解释

  • -Ddesktop-utils=false:直接禁用gio-launch-desktop等桌面工具的编译
  • -Djournald=false:关闭systemd journald支持,解决_g_fd_is_journal未定义的链接错误
  • -Dgio=false:完全禁用GIO模块,大幅缩小glib体积(仅当BlueZ不依赖GIO时使用)
  • -Dgio-modules=none:禁用GIO的额外模块,保留核心功能的同时避免不必要的依赖

关键说明

当前错误的根源是glib默认启用了journald支持,但交叉编译环境中缺少对应依赖库,同时桌面工具被默认编译。通过禁用这些非CLI必需的功能,既能满足BlueZ的依赖需求,又能生成更精简的glib库。


内容的提问来源于stack exchange,提问作者Daniel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 05:54:55