1

I'm confused as to how to use *-dev packages in Ubuntu.

I want to use the libxml2 library, in Ubuntu, for my own code development. I installed libxml2-dev using apt-get, which put the header files in the /usr/include/libxml2/libxml.

In order to include a header file, e.g. parse.h, I have to use the following path libxml2/libxml/parser.h. That works fine, but then I run into a cascade of problems.

parse.h, as written by the developer, include another header libxml/xmlversion.h. Unfortunately, that path is NOT consistent with how this -dev package headers files are stored in Ubuntu. That is, xmlversion.h needs to be called (at least by my program) as libxml2/libxml/xmlversion.h.

Likewise, xmlversion.h calls a header libxml/xmlexports.h which also not in the default search path, creating a cascading series of "No such file" errors.

I assume that I could solve this problem by manually specifying the search path to include /usr/local/libxml2, but this would seem to negate the benefit of using a package manager like apt-get. At the very least, I assume the package manager, when installing a *-dev package, will properly configure the compiler search paths

What am I missing in terms of using *-dev packages? Is this normal behavior or a specific problem to libxml2-dev? What does apt package manager expect me to do after installing an *-dev package?

1 Answer 1

2

The development packages usually include a configuration file for pkg-config in /usr/lib/pkgconfig. This program can be used (among other things) to query the needed c compiler and linker flags to use this library.

In the case of libxml2-dev the c compiler flags include -I/usr/include/libxml2:

$ pkg-config libxml-2.0 --cflags
-I/usr/include/libxml2

One way to use it would be:

gcc $(pkg-config libxml-2.0 --cflags --libs) main.c

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .