未定义的libxml2引用,但适用于另一个c文件

时间:2012-08-06 18:58:15

标签: c xml gcc linker libxml2

我使用libxml测试了this简单的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

对于this文件(更简单),此命令有效:

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

我也尝试过使用xmlsoft网站上的xml2-config脚本,但结果仍然相同。

我似乎无法在谷歌上找到任何东西。我还安装了dev个文件。如果有人能指出我正确的方向,那将是伟大的。感谢。

EDIT2

将源文件放在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  

0 个答案:

没有答案