[augeas-devel] [PATCH] pkg-config: Augeas requires libxml2

Richard W.M. Jones rjones at redhat.com
Sat Dec 3 13:55:55 UTC 2011


If you use pkg-config (augeas.pc) to locate the libraries needed for
Augeas, your program will fail to compile, with the following error:

  /usr/include/augeas.h:24:25: fatal error: libxml/tree.h: No such file or directory

This is because the pkg-config directives don't tell the program to
add the extra -I parameter for libxml2.

For a self-contained demonstration, see attachments #2, #3, #4.

Fixing this is simple -- see the patch in attachment #1.

Note with this patch, programs will also *link* against libxml2, ie:

  $ eu-readelf -d test | grep NEEDED
    NEEDED            Shared library: [libaugeas.so.0]
    NEEDED            Shared library: [libxml2.so.2]
    NEEDED            Shared library: [libc.so.6]

For many programs this is a case of over-linking.  The problem is that
we can't tell whether a program that includes <augeas.h> also uses the
aug_to_xml API (and hence xmlNode / libxml2).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-------------- next part --------------
>From f61ab0c52a503e52e1c6d4a2091179fa7ba75899 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Sat, 3 Dec 2011 13:46:25 +0000
Subject: [PATCH] pkg-config: Augeas requires libxml2.

---
 augeas.pc.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/augeas.pc.in b/augeas.pc.in
index c97847d..f6fd75a 100644
--- a/augeas.pc.in
+++ b/augeas.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: augeas
 Version: @VERSION@
 Description: Augeas configuration editing library
-Requires:
+Requires: libxml-2.0
 Libs: -L${libdir} -laugeas @LIBS@
 Cflags: -I${includedir}
-- 
1.7.6

-------------- next part --------------
A non-text attachment was scrubbed...
Name: configure.ac
Type: application/vnd.nokia.n-gage.ac+xml
Size: 201 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20111203/438e7825/attachment.ac>
-------------- next part --------------
bin_PROGRAMS = test
test_SOURCES = test.c
test_CFLAGS = $(AUGEAS_CFLAGS)
test_LDADD = $(AUGEAS_LIBS)
-------------- next part --------------
#include <augeas.h>

main ()
{
  augeas *aug;

  aug = aug_init ("/", NULL, 0);
  aug_close (aug);
  exit (EXIT_SUCCESS);
}


More information about the augeas-devel mailing list