[systemd-devel] Reusing systemd utils in a non-systemd application?

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Oct 20 05:30:23 PDT 2014


On Mon, Oct 20, 2014 at 07:19:42AM +0000, Chaiken, Alison wrote:
> There are some very useful functions in systemd/src/shared that are tempting to reuse in other, unrelated applications.    My first attempt is like this:
> 
> /usr/bin/gcc -g -Wall -Wextra -std=gnu99 -I../systemd/src/systemd -I../systemd/src/shared -I/usr/include/x86_64-linux-gnu/python2.7/ someprogram.c  ../systemd/src/shared/log.c -I. ../systemd/src/shared/util.c -o someprogram 
> 
> but the result doesn't come close to compiling:
> ===
> In file included from ../systemd/src/shared/log.c:33:0:
> ../systemd/src/shared/util.h:51:4: error: #error Unknown pid_t size
>  #  error Unknown pid_t size
>     ^
> In file included from ../systemd/src/shared/util.h:87:0,
>                  from ../systemd/src/shared/log.c:33:
> ../systemd/src/shared/missing.h:282:6: error: #error "neither secure_getenv nor __secure_getenv are available"
>  #    error "neither secure_getenv nor __secure_getenv are available"
>       ^
> ===
> and so on.    Is it necessary to understand libtool to proceed in this direction, or has someone already figured out how to refer to src/shared functions in a plain old Makefile for compilation outside of the systemd source tree?

Hi,

libsystemd-shared is an internal library. Technically it would not be
an issue to install it and make available for other users, but we
don't do that. The reason is that the library is subject to change at
any time and is made only as comprehensive as needed for a given version
of systemd code, the API is not stable, in some places it uses systemd
logging framework, is undocumented and makes various assumptions that
might be correct for internal use, but not in a general purpose library.
Nevertheless, it is LGPLv2+ and you can use it for any purpose, either
by copying or building it is part of systemd and linking to that, at
you own risk. To link to it, simply compile systemd as normal, the
library is called libsystemd-shared.a (a static library).

Zbyszek


More information about the systemd-devel mailing list