News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

[SOLVED] libxml2 include header files directory

Started by cbuser2, October 13, 2012, 01:09:54 AM

Previous topic - Next topic

cbuser2

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.


stahta01

#1
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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cbuser2

Quote from: stahta01 on October 13, 2012, 01:29:28 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.


stahta01

#3
Quote from: cbuser2 on October 13, 2012, 03:27:37 AM
Quote from: stahta01 on October 13, 2012, 01:29:28 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.

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cbuser2

I believe that I've done everything that you've suggested, but still getting the error message. Very weird.




cbuser2

Oh yes, I am trying to use the limxml2 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.

cbuser2

#6
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"


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




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.


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




Thanks for your replies, stahta01.

Jenna

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.