Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: cbuser2 on October 13, 2012, 01:09:54 am

Title: [SOLVED] libxml2 include header files directory
Post by: cbuser2 on October 13, 2012, 01:09:54 am
Hi all. :)

I have header files in: /usr/include/libxml2/libxml/. This directory has the header file "parser.h", and other header files.

I go to project -> build options -> compiler -> search directories and add /usr/include/libxml2/libxml/

But the compiler gives the error: parser.h: no such file or directory. If I include the header file as an absolute path ie. "/usr/include/libxml2/libxml/parser.h", then the compiler would not give that error, but would now give another error about another header file which is also in the same directory.

I don't want to add absolute paths for multiple files, so what can I do? Thanks in advance.

Title: Re: include header directory
Post by: stahta01 on October 13, 2012, 01:29:28 am
Did you try just adding /usr/include/libxml2 to the include search path?

You likely need to read the library directions on the proper include method.

If it is
#include "libxml/parser.h"
then what I suggest is correct.

Edit: added normal option to try below.

Under "Global Compiler Settings"
Tab "build options"
Try checking "Explicitly add current compiling file's directory ...."

Tim S.
Title: Re: include header directory
Post by: cbuser2 on October 13, 2012, 03:27:37 am
Did you try just adding /usr/include/libxml2 to the include search path? ....

Under "Global Compiler Settings"
Tab "build options"
Try checking "Explicitly add current compiling file's directory ...."

I can't find the include search path option in the settings.  And neither can I find the "build options" tab, even though I can find "Global Compiler Settings". I am using CB 10.05. Thank you.

(http://i538.photobucket.com/albums/ff349/pluckaduck2/codeblocks.png)
Title: Re: include header directory
Post by: stahta01 on October 13, 2012, 04:23:11 am
Did you try just adding /usr/include/libxml2 to the include search path? ....

Under "Global Compiler Settings"
Tab "build options"
Try checking "Explicitly add current compiling file's directory ...."

I can't find the include search path option in the settings.  And neither can I find the "build options" tab, even though I can find "Global Compiler Settings". I am using CB 10.05. Thank you.



In 10.05 under Windows you need the "other setting" tab the far right tab use likely need to use arrows to get it it.

By 'include search path' I mean the compiler search directory setting.

Tim S.

Title: Re: include header directory
Post by: cbuser2 on October 13, 2012, 06:14:00 am
I believe that I've done everything that you've suggested, but still getting the error message. Very weird.

(http://i538.photobucket.com/albums/ff349/pluckaduck2/codeb1.png)

(http://i538.photobucket.com/albums/ff349/pluckaduck2/codeb2.png)
Title: Re: include header directory
Post by: cbuser2 on October 13, 2012, 06:54:00 am
Oh yes, I am trying to use the limxml2 (http://www.xmlsoft.org/) html parsing library, in linux. So if anyone has managed to do this, including setting up the header directories in CB, I'd really like to know what your settings are in CB.
Title: Re: include header directory
Post by: cbuser2 on October 13, 2012, 04:06:29 pm
Ok, problem solved, by reading the FAQ properly: http://www.xmlsoft.org/FAQ.html#Installati

"Troubles compiling or linking programs using libxml2

Usually the problem comes from the fact that the compiler doesn't get the right compilation or linking flags. There is a small shell script xml2-config which is installed as part of libxml2 usual install process which provides those flags. Use

xml2-config --cflags

to get the compilation flags"

Code
mycomputer$ xml2-config --cflags
-I/usr/include/libxml2

(http://i538.photobucket.com/albums/ff349/pluckaduck2/codeb3.png)

And for those who have trouble with setting up the linker library, the library file ends in .so, and since I am using 64 bit linux.

Code
mycomputer$ locate libxml2.so
/usr/lib/i386-linux-gnu/libxml2.so.2
/usr/lib/i386-linux-gnu/libxml2.so.2.7.8
/usr/lib/x86_64-linux-gnu/libxml2.so
/usr/lib/x86_64-linux-gnu/libxml2.so.2
/usr/lib/x86_64-linux-gnu/libxml2.so.2.7.8

(http://i538.photobucket.com/albums/ff349/pluckaduck2/codeb4.png)

Thanks for your replies, stahta01.
Title: Re: [SOLVED] libxml2 include header files directory
Post by: Jenna on October 13, 2012, 04:28:16 pm
The best solution is in my opinion to use `xml2-config --cflags` and `xml2-config --libs` (note the backticks) in the compilers/linkers other options tab.