Help with #include sentences

Hello. I need some help with code :slight_smile:
I’m trying to port a program with the following includes:

#include <libxml/xmlversion.h>
#include <libxml/tree.h>

However, when compile it, shows the following error:

fatal error: libxml/xmlversion.h: No such file or directory

I have the packages libxml and libxml_x86 installed. The path where the .h files are stored is:
/boot/system/develop/headers/libxml2/libxml/
/boot/system/develop/headers/x86/libxml2/libxml/

I guess the #include sentences are wrong, but in Haiku, what must be the path to the needed .h files?

Thank you!

Ooops… sorry… I guess I found the answer myself:

the include sentences must be changed to < libxml2/libxml/xmlversion.h>

:blush:

Alternatively, and maybe more correctly, you can see:

pkg-config --cflags libxml-2.0

Which returns:

-I/packages/libxml2-2.8.0-9/.self/develop/headers/libxml2

So, you can add it to your compiler flags, and then use the “normal” include path. This is more correct because if the library includes are moved around, things will still work as expected.

Adding pkg-config to compiler flags inside a makefile:

CFLAGS += $(shell pkg-config --cflags libxml-2.0)

PS: forum pro-tip: indent text with 4 spaces to disable the automatic formatting.

2 Likes

Thank you for you help, PulkoMandy!