[systemd-devel] Reusing systemd utils in a non-systemd application?
Lennart Poettering
lennart at poettering.net
Mon Oct 20 07:59:53 PDT 2014
On Mon, 20.10.14 07:19, Chaiken, Alison (Alison_Chaiken at mentor.com) 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?
it's an internal library of systemd, we do not export it since we
don#t want to make ABI guarantees for it.
If you want to use it in your own project you can copy it under LGPL2
as usual. Some of the code requires some autoconf checks to be done
though, in the above two cases you need:
AC_CHECK_SIZEOF(pid_t)
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
Note that there might be more checks necessary to make the code
correctly work, even though it won't result in immediate compile
errors if the checks are missing. I'd thus recommend only copying the
actual functions you need and looking at them in detail for autoconf
macros you need for them.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list