Author Topic: [SOLVED] libxml2 include header files directory  (Read 38250 times)

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
[SOLVED] libxml2 include header files directory
« 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.

« Last Edit: October 13, 2012, 04:10:16 pm by cbuser2 »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: include header directory
« Reply #1 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.
« Last Edit: October 13, 2012, 01:39:41 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: include header directory
« Reply #2 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.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: include header directory
« Reply #3 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.

« Last Edit: October 13, 2012, 04:29:27 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: include header directory
« Reply #4 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.




Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: include header directory
« Reply #5 on: October 13, 2012, 06:54:00 am »
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.

Offline cbuser2

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: include header directory
« Reply #6 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



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



Thanks for your replies, stahta01.
« Last Edit: October 13, 2012, 04:14:20 pm by cbuser2 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: [SOLVED] libxml2 include header files directory
« Reply #7 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.