GNOME Bugzilla – Bug 711026
Static linking improvements
Last modified: 2013-12-21 10:35:58 UTC
A couple of patches coming with improvements for statically linking against libxml2 and its dependencies.
Created attachment 258320 [details] [review] build: Add @LZMA_LIBS@ to libxml’s pkg-config files If libxml2 is built and linked against liblzma, the latter needs to appear in libxml2’s Libs.private pkg-config field, otherwise static linking against libxml2 will fail due to unresolved liblzma symbols.
Created attachment 258321 [details] [review] build: Use pkg-config to find liblzma instead of AC_CHECK_LIB This means that liblzma’s Libs.private will be included in LZMA_LIBS if linking the libraries statically, ensuring that there are no undefined symbol errors from liblzma’s private libraries.
Sorry, but last patch is not okay for libxml2, the portability requirement is that it needs to configure even if pkg-config is not available. it's okay to try to use it and fallback to normal detection though in case of problem. Daniel
Created attachment 258424 [details] [review] build: Use pkg-config to find liblzma in preference to AC_CHECK_LIB This means that liblzma’s Libs.private will be included in LZMA_LIBS if linking the libraries statically, ensuring that there are no undefined symbol errors from liblzma’s private libraries. If pkg-config isn’t installed, or if liblzma.pc couldn’t be found, fall back to using AC_CHECK_LIB as before. This will cause static linking to fail, but that’s not a regression. This does not introduce a compile time dependency on pkg-config.
Sorry i had commited to my branch but forgot to push and notify here https://git.gnome.org/browse/libxml2/commit/?id=f859d9a78350246222185a9605ae65da8ce42cea i think this fixes it, thanks ! Daniel
Actually no, a separate patch i got confused, pushed :-) https://git.gnome.org/browse/libxml2/commit/?id=f3f86ff465c92c79f834d7b981f3c7274a8bb5c8 thanks, Daniel
The commit "Use pkg-config to find liblzma in preference to AC_CHECK_LIB" does introduce a compile time dependency on pkg-config when compiling from Git. The configure script generated with autogen.sh fails if pkg.m4 isn't installed.
You can either ship a copy of pkg.m4 in the libxml2 tarball, or inline the contents of the PKG_CHECK_MODULES macro in configure.ac. Which platforms don’t have pkg-config support? Would it perhaps be more worthwhile to port pkg-config to those platforms, given how widely it’s used in software build systems?