title: Undefined reference to libxml2 but works on another c file
body: <p>I tested <a href="http://www.xmlsoft.org/examples/parse1.c" rel="nofollow">this</a> simple c file using libxml and it works fine, so I know that I have libxml installed correctly. However I tired running another file that has only this include statement <code>#include &lt;libxml/xmlreader.h&gt;</code> and I get all these linking errors:</p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>/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'
  </code></pre>
  
  <p><strong>EDIT</strong>:
  This is the command line I am using to compile the code:</p>
  
  <pre class="lang-none prettyprint-override"><code>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
  </code></pre>
  
  <p>for <a href="http://www.xmlsoft.org/examples/parse1.c" rel="nofollow">this</a> file (simpler), this command works:</p>
  
  <pre class="lang-none prettyprint-override"><code>gcc -g  `pkg-config --cflags --libs libxml-2.0`  simplierFile.c
  </code></pre>
  
  <p>I also tried using the script <code>xml2-config</code> from the xmlsoft site but still same result.</p>
  
  <p>I can't seem to find anything on google. I also have installed the <code>dev</code> files. If someone can point me in the right direction that would be great. Thanks.</p>
  
  <p><strong>EDIT2</strong>:</p>
  
  <p>Putting the source file before <code>pkg-config</code> doesn't work.</p>
  
  <p>From the errors it seems that it is not linking libxml correctly.</p>
  
  <p><strong>EDIT3</strong>
  The output of <code>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</code> is: </p>
  
  <pre class="lang-none prettyprint-override"><code>-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  
  </code></pre>