ubuntu-22.04gcc12

Ubuntu 22.04 Undefined reference to 'sd_notify'


I am trying to build something I need which I downloaded from: https://github.com/izot/lon-driver

Unfortunately the build instructions are non-existent and there doesn't appear to be a way to ask for assistance either.

I have downloaded using git to my virtual machine which is Ubuntu 22.04, I am trying to compile the file in lonifd using:

gcc lonifd.c

The result is:

/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

I've search around for solutions and have updated gcc which is now:

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 version: git version 2.34.1


Solution

  • install: libsystemd-dev

    Then gcc lonifd.c -lsystemd

    should work (tested on ubuntu 18.04)