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

Ubuntu 22.04编译lon-driver遇sd_notify未定义引用错误求助

编译lon-driver项目时遇到sd_notify未定义引用错误

问题详情

  • 将lon-driver项目克隆至Ubuntu 22.04虚拟机,项目无构建文档且无法获取官方技术支持。
  • 执行编译命令 gcc lonifd.c 时触发链接错误:
/usr/bin/ld: /tmp/ccJleZ8s.o: in function `main':
lonifd.c:(.text+0x3882): undefined reference to `sd_notify'
collect2: error: ld returned 1 exit status
  • 已将GCC更新至12.3.0版本,版本信息如下:
gcc --version
gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • 当前Git版本:git version 2.34.1

解决方案

sd_notify 是systemd库提供的函数,编译时需要显式链接systemd库。将编译命令修改为:

gcc lonifd.c -lsystemd

如果系统中未安装systemd开发库,需先执行以下命令安装:

sudo apt-get install libsystemd-dev

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 07:12:07