简体   繁体   中英

libxml/parser.h: in c++ ubuntu

即使我再次在ubuntu 12.04版本中安装了libxml ++ 2.6-2 libxml ++ 2.6-doc等,我仍收到以下致命错误:libxml / parser.h:我没有这样的文件或目录,我正在使用make进行构建该项目

     Kindly suggest any other libxml libraries which I need to install
  1. libxml/parser.h is a part o libxml library, not libxml++

  2. For any given library, you need development packages (the ones with names ending in -dev ) in order to build applications using that library.

  3. You need to pass additional flags to your compiler: xml2-config --cflags and to linker xml2-config --libs .

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, eg:
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.

在将答案发布给已回答的人之前,谢谢,但这些答案对我没有用

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. 

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 ie /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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM