How to use `libxml2` headers in a package?

I am trying to build Canon printer driver on my repo for this issue but stuck with missing header.

data_process.c:28:10: fatal error: libxml/parser.h: No such file or directory
 #include <libxml/parser.h>
           ^~~~~~~~~~~~~~~~~

I found the missing header in libxml2.dev (using nix-build '<nixpkgs>' -A libxml2.dev and inspect the result-dev directory)

but when I try to use it in the expression capt.nix at line #62 it failed with

/nix/store/7r0yjzdjc2lymjszcxcv220z7hkvzw70-stdenv-linux/setup: line 1338: -I/nix/store/im853gaq498i1pha0lhvzjlylh2sjbwq-libxml2-2.9.9-dev/include/libxml2: No such file or directory

Hi!

Short story: you are missing quotes around the env var definition, so the include is taken as the executable by bash.

       autoreconf -fi
       LDFLAGS=-L${cndrvcups-common}/usr/lib \
         LIBS='-lpthread -lgdk-x11-2.0 -lgobject-2.0 -lglib-2.0 -latk-1.0 -lgdk_pixbuf-2.0' \
-        CPPFLAGS=-I${cndrvcups-common}/usr/include -I${libxml2.dev}/include/libxml2 \
+        CPPFLAGS="-I${cndrvcups-common}/usr/include -I${libxml2.dev}/include/libxml2" \
         ./autogen.sh --prefix=$out/usr --disable-static
     popd

Then, I got a bit carried away, with cleanups and fixing the source code for a missing include… All of this can be seen on your repo, at https://github.com/wizzup/canon-capt/pull/2

Please ask if anything is unclear in that changeset.

3 Likes

Thank you :heart:, I will continue the process there.