libxml/parser.h: in c++ ubuntu

libxml/parser.h: in c++ ubuntu

本文关键字:in c++ ubuntu parser libxml      更新时间:2023-10-16

即使我已经在我的 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.hlibxml库的一部分,而不是libxml++

  2. 对于任何给定的库,您需要开发包(名称以 -dev 结尾的包(才能使用该库构建应用程序。

  3. 您需要将其他标志传递给编译器:xml2-config --cflags 和链接器xml2-config --libs

我现在无法访问 Ubuntu 系统,但是: 也许您需要安装 libxml 开发人员包?也许您只有库但没有包含文件?

入住/usr/include/usr/local/include , ...对于目录libxml和文件parser.h

如果找到该文件,则可能需要调整makefile,以便父目录位于包含路径列表中,例如:
INC = -I/usr/local/include g++ $(INC) ...

如果未找到该文件:请检查开发人员软件包的可用 libxml 软件包并安装该文件。

在发布答案之前 感谢回答的人,但这些答案对我不起作用

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. 

在阅读本文之前,请阅读@el.pescado 答案。我想评论这个答案,但觉得有必要更好地格式化我的代码。

gcc -c <files to compile> `xml2-config --cflags` -o <object files>
gcc <object files> -L<libxml2 lib location> `xml2-config --libs` -o <binary file>

假设我们有一个文件名xmltest.c其代码包含libxml2标头,如#include <libxml/parser.h>,共享库的标准位置libxml2/usr/lib64/libxml2,上面的代码将像这样计算:

gcc -c xmltest.c -I/usr/include/libxml2 -o xmltest.o
gcc xmltest.o -L/usr/lib64/libxml2 -lxml2 -lz -lm -o xmltest

更好的主意是将自动执行此操作的Makefile放在一起。