1

我使用 libxml 测试了这个简单的 c 文件,它工作正常,所以我知道我已经正确安装了 libxml。但是我厌倦了运行另一个只有这个包含语句的文件,#include <libxml/xmlreader.h>并且我得到了所有这些链接错误:

/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlParseMemory@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlFree@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlStrcasecmp@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlStrdup@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderRead@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderConstName@LIBXML2_2.6.0'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderGetAttribute@LIBXML2_2.5.0'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlGetProp@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderDepth@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderConstXmlLang@LIBXML2_2.6.0'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlNodeListGetString@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlNewTextReaderFilename@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlFreeDoc@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderNodeType@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlGetLineNo@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlTextReaderName@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlKeepBlanksDefault@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlStrcmp@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlReaderForFd@LIBXML2_2.6.0'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgtksourceview-1.0.so: undefined reference to `xmlDocGetRootElement@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlFreeTextReader@LIBXML2_2.4.30'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libgnomevfs-2.so: undefined reference to `xmlTextReaderConstValue@LIBXML2_2.6.0'

编辑:这是我用来编译代码的命令行:

gcc -g  `pkg-config --cflags --libs gtk+-2.0 cairo libgvc glib-2.0 \
  gtksourceview-1.0 gnome-vfs-2.0 libgnomeprintui-2.2 libxml-2.0`  test-widget.c

对于这个文件(更简单),这个命令有效:

gcc -g  `pkg-config --cflags --libs libxml-2.0`  simplierFile.c

我还尝试使用xml2-configxmlsoft 站点中的脚本,但结果仍然相同。

我似乎在谷歌上找不到任何东西。我也安装了dev文件。如果有人能指出我正确的方向,那就太好了。谢谢。

编辑2

将源文件放在之前pkg-config不起作用。

从错误看来,它似乎没有正确链接 libxml。

EDIT3 的输出pkg-config --cflags --libs gtk+-2.0 cairo libgvc glib-2.0 gtksourceview-1.0 gnome-vfs-2.0 libgnomeprintui-2.2 libxml-2.0是:

-pthread -DORBIT2=1 -I/usr/local/include/atk-1.0 -I/usr/local/include/gdk-pixbuf-2.0
 -I/usr/local/include/pango-1.0 -I/usr/local/include/gio-unix-2.0/ -I/usr/local/include
/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include/libxml2 -I/usr/local
/include/libgnomeprint-2.2 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include
/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr
/include/graphviz -I/usr/include/gtksourceview-1.0 -I/usr/include/libart-2.0 -I/usr/include
/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include -I/usr/include/gconf/2 -I/usr/include
/orbit-2.0 -I/usr/include/libgnomeprintui-2.2 -I/usr/include/libgnomecanvas-2.0 -I/usr
/include/gail-1.0  -pthread -L/usr/local/lib -lgvc -lgraph -lcdt -lgtksourceview-1.0 
-lgnomevfs-2 -lgconf-2 -lgthread-2.0 -lgnomeprintui-2-2 -lgnomeprint-2-2 -lz 
-lgnomecanvas-2 -lgmodule-2.0 -lrt -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 
-lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype 
-lfontconfig -lgobject-2.0 -lglib-2.0 -lxml2  
4

0 回答 0