Reputation: 127
Even though I have installed libxml++2.6-2 libxml++2.6-doc etc in my ubuntu 12.04 version again I am getting the below error fatal error: libxml/parser.h: No such file or directory I am using make for building the project
Kindly suggest any other libxml libraries which I need to install
Upvotes: 0
Views: 5575
Reputation: 1646
Please read @el.pescado answer before reading this. I wanted to comment on that answer but felt the need to format my code better.
gcc -c <files to compile> `xml2-config --cflags` -o <object files>
gcc <object files> -L<libxml2 lib location> `xml2-config --libs` -o <binary file>
Assuming we have a file names xmltest.c
that have code that included libxml2
header like #include <libxml/parser.h>
, standard location of libxml2
shared library i.e. /usr/lib64/libxml2
, the above code will evaluate like this:
gcc -c xmltest.c -I/usr/include/libxml2 -o xmltest.o
gcc xmltest.o -L/usr/lib64/libxml2 -lxml2 -lz -lm -o xmltest
A better idea is to put together a Makefile
that does this automatically.
Upvotes: 0
Reputation: 127
Before Posting the answer THANKS to the people who have answered, but those answers were not worked for me
I have just copied libxml folder from the directory usr/lib/libxml2 and pasted in usr/lib directory and compiled my code it is not giving any error. It is working fine now.
Upvotes: 0
Reputation: 19236
libxml/parser.h
is a part o libxml
library, not libxml++
For any given library, you need development packages (the ones with names ending in -dev
) in order to build applications using that library.
You need to pass additional flags to your compiler: xml2-config --cflags
and to linker xml2-config --libs
.
Upvotes: 2
Reputation: 2466
I don't have access to an Ubuntu system now, but: Maybe you need to install the libxml developer package? Maybe you only have the library but not the include file(s)?
Check in /usr/include
, /usr/local/include
, ... for the directory libxml
and the file parser.h
.
If you find the file, you may need to adapt your makefile so that the parent-directory is in the list of include paths, e.g.:
INC = -I/usr/local/include
g++ $(INC) ...
If you did not find the file: Check the available libxml packages for a developer package and install that.
Upvotes: 0