I have an ARM Tinkerboard running Debian 9.8 (Stretch). Systemd version is 232. I'm working on a program that can be run from userland or as a daemon. If it is run as a daemon, then dlopen and dlsym are used to locate Systemd sd_notify(3) entry points.

According to the sd_notify(3) man page:

These APIs are implemented as a shared library, which can be compiled and linked to with the libsystemd pkg-config(1) file.

Unfortunately, I cannot find libsystemd.so. This is a userland test to simulate a service load:

$ LD_PRELOAD=/lib/libsystemd.so NOTIFY_SOCKET=-1 ./myprog.exe
ERROR: ld.so: object '/lib/libsystemd.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

It does not seem to be located in the standard locations:

$ find /lib -name libsystemd.so
$ find /usr -name libsystemd.so

In fact:

$ sudo find / -name libsystemd.so

Where is the shared library located?


libsystemd.so is a symbolic link provided by the libsystemd-dev package, which is only useful to build programs that use the library. Its target is libsystemd.so.0 which is provided by the libsystemd0 package, which provides what is needed to run programs that use the library. If you could find libsystemd.so on your PC but not on your Arm device, it's because you've installed a development environment environment on your PC but not in the Arm device.

This is the case for most libraries. The library file that programs use contains a version number: libfoo.so.VERSION. This allows the system to have multiple incompatible versions of the library: each version is identified by a number and is its own file. The Debian package name also includes the library version number: libfooVERSION. If you have the development files for the library (headers and the static library libfoo.a), they come with a symbolic link libfoo.so pointing to the version of the library that the programs you build will use.

So run find /lib /usr/lib -name libsystemd.so.0.
Or run ldd against any executable that is dynamically linked against the library (as opposed to loading it at runtime with dlopen), e.g. ldd /usr/bin/dbus-daemon.
Or search installed packages with dpkg -S libsystemd.so.0.
Or search available packages with apt-file search libsystemd.so.0 (assuming apt-file is set up).
Or look it up online.

LD_PRELOAD=/lib/arm-linux-gnueabihf/libsystemd.so.0 …
  • Thanks Giles. I did not realize it did not use the name libsystemd.so. I thought that symlink always existed. I did not need to install it once I used the correct name. Preloading /lib/arm-linux-gnueabihf/libsystemd.so.0 caused an error. I needed LD_PRELOAD=/lib/systemd/libsystemd-shared-232.so. If interested: libsystemd.so locations on Tinkerboard – user56041 Apr 19 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy