Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler can't find libxml/parser.h

I am on Debian 8 (Jessie), 64 Bit. I installed libxml2-dev, which now sits in /usr/include/libxml2/libxml.

But when I do (just like libxml docs say)

#include <libxml/parser.h>

I only get when compiling (with gcc)

fatal error: libxml/parser.h: no such file or directory

Notes: On another machine, with an old 64 Bit Suse, where libxml2-dev sits in the exact same path and no other environment vars are set compared to the new Debian, it works perfectly fine. Problem occured while migrating from one to another computer using the exact same makefiles. All other -dev libs that I need just worked (with their documented #include <path>) after the migration (they were all installed with apt-get), only libxml2-dev is not found on compilation.

Do I need to do anything else to make libxml2-dev visible?

like image 968
Foo Bar Avatar asked Apr 24 '15 12:04

Foo Bar


4 Answers

Try to compile with explicite inclusion where the parser.h file is, i.e. smth like this

g++ -I/usr/include/libxml2/


Following environment variables can also be used for lookup of header files

CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH

Find more information here

like image 136
deimus Avatar answered Nov 19 '22 07:11

deimus


if you installed it: sudo apt-get install libxml2-dev libxml2-doc go into /usr/include/libxml2 and copy or move all content from that folder on a level below: cp -R libxml/ ../ After this for me it works.

like image 39
Volodymyr Avatar answered Nov 19 '22 06:11

Volodymyr


I came across this same problem on a Centos system. I resolved it by doing the following:

yum install libxml2-devel
cd /usr/include
ln -s libxml2/libxml .

That was it. No change to environment variables or compiler switches.

like image 4
Pat Avatar answered Nov 19 '22 07:11

Pat


You should use pkg-config to pass parameters to compiler. Like this

g++ `pkg-config --cflags libxml-2.0` example.c -o example.o

and to linker:

g++ `pkg-config --libs libxml-2.0` example.o -o example
like image 1
BЈовић Avatar answered Nov 19 '22 07:11

BЈовић