With modern libraries, there is (or should be) no need to hard-code an install path (what if libxml2 is in /opt, or /usr/local/libxml2, or wherever?). Instead, libxml2 makes use of pkg-config, so you should use:
Code:
pkg-config libxml-2.0 --cflags
when building, and
Code:
pkg-config libxml-2.0 --libs
when linking. This takes care of include and library paths, and library names.
If your system doesn't have pkg-config, libxml2 should also come with xml2-config, which performs the same function.
pkg-config allows multiple packages to be specified, which is very handy:
Code:
pkg-config libfoo libbar libbaz --cflags
Duplicate entries are merged into one (so if all set -I/usr/local/include, this is only output once).
In GNU make, for example, you could do:
Code:
PACKAGES= libxml-2.0 imlib2 x11
CFLAGS+= $(shell pkg-config $(PACKAGES) --cflags)
LDADD+= $(shell pkg-config $(PACKAGES) --libs)
Encourage library authors to use pkg-config! Encourage library users to use pkg-config!