Your linker flags need to come after your input source files:

g++ `pkg-config --cflags libsystemd` -o syslog-test syslog-test.cpp
`pkg-config --libs libsystemd`

** Changed in: systemd (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/2103853

Title:
  sd_journal_send_with_location not in libsystemd in Ubuntu 24.04 RT
  raspi

Status in systemd package in Ubuntu:
  Invalid

Bug description:
  When linking a simple program, the symbol is not found.

  Program:
  #include <iostream>
  #include <systemd/sd-journal.h>

  int main( int argc, char * argv[] )
  {
      sd_journal_send( "MESSAGE=Begin test",
                     "MESSAGE_ID=test",
                     nullptr );
      std::cout << "test" << std::endl;
  }

  Build command:
  g++ `pkg-config --cflags libsystemd` -o syslog-test `pkg-config --libs 
libsystemd` syslog-test.cpp
  /usr/bin/ld: /tmp/cczTBtWR.o: in function `main':
  syslog-test.cpp:(.text+0x3c): undefined reference to 
`sd_journal_send_with_location'
  collect2: error: ld returned 1 exit status

  ProblemType: Bug
  DistroRelease: Ubuntu 24.04
  Package: libsystemd-dev 255.4-1ubuntu8.6
  ProcVersionSignature: Ubuntu 6.8.0-2019.20-raspi-realtime 6.8.12
  Uname: Linux 6.8.0-2019-raspi-realtime aarch64
  ApportVersion: 2.28.1-0ubuntu3.5
  Architecture: arm64
  CasperMD5CheckResult: unknown
  CloudArchitecture: aarch64
  CloudID: none
  CloudName: none
  CloudPlatform: none
  CloudSubPlatform: config
  Date: Sat Mar 22 09:46:23 2025
  ProcEnviron:
   LANG=C.UTF-8
   PATH=(custom, no user)
   SHELL=/bin/bash
   TERM=dumb
   XDG_RUNTIME_DIR=<set>
  SourcePackage: systemd
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2103853/+subscriptions


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to