0

I want to use libxml2 as parser for a c program on a system with ubuntu. I used the following command to install libxml2:

sudo apt-get install -y libxml2-dev

I try to compile the following file: http://xmlsoft.org/examples/reader1.c My makefile looks like this:

xml_reader: xml_reader.o
    gcc -o xml_reader xml_reader.o -lxml2 -lm
    
xml_reader.c: xml_reader.c
    gcc -c xml_reader.c -I/usr/include/libxml2
    

But sadly I get the following response:

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

Did I miss something, which I had to do before compiling or am I even using the right -l argument?

0

1 Answer 1

2

The target of your second Makefile rule should be xml_reader.o and not xml_reader.c. Right now make is using a default rule instead which does not make use of -I/usr/include/libxml2 and thus gcc cannot find the required header.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.