Adding external library dependencies to .pc files for static linking
Wolfgang Walther
walther at technowledgy.de
Wed Feb 28 13:09:35 EST 2024
When building static krb5 libraries --with-keyutils, mit-krb5.pc will
not contain any references to keyutils. This makes linking statically
against krb5 fail when relying on pkg-config to provide the linker flags.
A related issue was discussed in [1] but back then, there was no
pkg-config support to start with. Also, in krb5-config.in there is this
comment:
# If we ever support a flag to generate output suitable for static
# linking, we would output "-lkrb5support $GEN_LIB $LIBS $DL_LIB"
# here.
Because keyutils does not ship pkg-config files itself, the right place
to add those is Libs.private. From [2]:
> My library z uses libx internally, but does not expose libx data types in its public API. What do I put in my z.pc file?
>
> Again, add the module to Requires.private if it supports pkg-config. [...] If libx does not support pkg-config, add the necessary linker flags to Libs.private.
Thus, I came up with the attached.
This fixes my downstream build, but it also does so when I only add
@LIBS@ and not the other two. I can't really tell whether adding those 3
is still correct/sufficient in the general case, given that the comment
above is 13 years old.
Best,
Wolfgang
[1]: https://krbdev.mit.edu/rt/Ticket/Display.html?id=3887
[2]: https://people.freedesktop.org/~dbn/pkg-config-guide.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-external-library-dependencies-to-pkg-config-s-Li.patch
Type: text/x-patch
Size: 797 bytes
Desc: not available
URL: <http://mailman.mit.edu/pipermail/krbdev/attachments/20240228/32e181d2/attachment.bin>
More information about the krbdev
mailing list