title: How to resolve "relocation truncated to fit: R_X86_64_PC32 against undefined symbol `xmlStrcmp'"
body: <p>I'm trying to use the libxml2 library in C++, but I get some errors which I do not know how to solve. My code is a basic example of the library.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;libxml/xmlmemory.h&gt;
  #include &lt;libxml/parser.h&gt;
  
  void
  parseStory (xmlDocPtr doc, xmlNodePtr cur) {
  
      xmlChar *key;
      cur = cur-&gt;xmlChildrenNode;
      while (cur != NULL) {
          if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)"keyword"))) {
              key = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
              printf("keyword: %s\n", key);
              xmlFree(key);
          }
      cur = cur-&gt;next;
      }
      return;
  }
  
  static void
  parseDoc(char *docname) {
  
      xmlDocPtr doc;
      xmlNodePtr cur;
  
      doc = xmlParseFile(docname);
  
      if (doc == NULL ) {
          fprintf(stderr,"Document not parsed successfully. \n");
          return;
      }
  
      cur = xmlDocGetRootElement(doc);
  
      if (cur == NULL) {
          fprintf(stderr,"empty document\n");
          xmlFreeDoc(doc);
          return;
      }
  
      if (xmlStrcmp(cur-&gt;name, (const xmlChar *) "story")) {
          fprintf(stderr,"document of the wrong type, root node != story");
          xmlFreeDoc(doc);
          return;
      }
  
      cur = cur-&gt;xmlChildrenNode;
      while (cur != NULL) {
          if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)"storyinfo"))){
              parseStory (doc, cur);
          }
  
      cur = cur-&gt;next;
      }
  
      xmlFreeDoc(doc);
      return;
  }
  
  int
  main(int argc, char **argv) {
  
      char *docname;
  
      if (argc &lt;= 1) {
          printf("Usage: %s docname\n", argv[0]);
          return(0);
      }
  
      docname = argv[1];
      parseDoc (docname);
  
      return (1);
  }
  </code></pre>
  
  <p>And I get these errors while building the project.</p>
  
  <blockquote>
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:26:
    undefined reference to `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:26:(.text+0x36):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:27:
    undefined reference to `xmlNodeListGetString'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:27:(.text+0x59):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlNodeListGetString' </p>
    
    <p>build/Debug/Cygwin-Windows/main.o: In function
    <code>parseDoc':
    /cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:42:
    undefined reference to</code>xmlParseFile'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:42:(.text+0xad):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlParseFile'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:49:
    undefined reference to `xmlDocGetRootElement'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:49:(.text+0xec):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlDocGetRootElement'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:53:
    undefined reference to `xmlFreeDoc'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:53:(.text+0x126):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlFreeDoc'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:57:
    undefined reference to `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:57:(.text+0x142):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:59:
    undefined reference to `xmlFreeDoc'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:59:(.text+0x17a):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlFreeDoc'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:65:
    undefined reference to `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:65:(.text+0x1a6):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlStrcmp'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:72:
    undefined reference to `xmlFreeDoc'</p>
    
    <p>/cygdrive/c/Users/robin/Documents/NetBeansProjects/xml/main.cpp:72:(.text+0x1d9):
    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    `xmlFreeDoc'</p>
    
    <p>build/Debug/Cygwin-Windows/main.o:main.cpp:(.rdata$.refptr.xmlFree[.refptr.xmlFree]+0x0):
    undefined reference to `xmlFree'</p>
  </blockquote>
  
  <p>I've read this post <a href="https://stackoverflow.com/questions/10486116/what-does-this-gcc-error-relocation-truncated-to-fit-mean">What does this GCC error &quot;... relocation truncated to fit...&quot; mean?</a>, but I have no clue how to solve my problem. My IDE is Netbeans 8.2 with Cygwin64 on a Windows 10 64 bit machine. I've included <em>libxml2-2.9.3-win32-x86_64.7z</em> and <em>iconv-1.14-win32-x86_64.7z</em>. I hope you can help me, thank you.</p>