title: expat undefined reference to `XML_SetElementHandler'
body: <p>I am getting these  linker errors when i build my program using expat xml library . </p>
  
  <pre><code>3288 /tmp/ccFZziQa.o: In function `xml::node::load_xml(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)':
  3289 node.cpp:(.text+0xdec): undefined reference to `XML_SetElementHandler'
  3290 node.cpp:(.text+0xe08): undefined reference to `XML_SetCharacterDataHandler'
  3291 node.cpp:(.text+0xe2c): undefined reference to `XML_SetUserData'
  3292 node.cpp:(.text+0xe72): undefined reference to `XML_Parse'
  3293 node.cpp:(.text+0xeaa): undefined reference to `XML_GetErrorCode'
  3294 node.cpp:(.text+0xeb1): undefined reference to `XML_ErrorString'
  3295 node.cpp:(.text+0xecb): undefined reference to `XML_GetCurrentLineNumber'
  </code></pre>
  
  <p><strong>build instruction :</strong> </p>
  
  <pre><code>g++ -v  -L /usr/lib/x86_64-linux-gnu -lexpat node.cpp
  </code></pre>
  
  <p><strong>library is there on filesystem:</strong></p>
  
  <p>$ locate libexpat.so </p>
  
  <pre><code>/lib/x86_64-linux-gnu/libexpat.so.1
  /lib/x86_64-linux-gnu/libexpat.so.1.6.0
  /usr/lib/x86_64-linux-gnu/libexpat.so
  </code></pre>
  
  <p><strong>Ran strace to check if any obvious issue :</strong> </p>
  
  <pre><code>2170 [pid  3361] open("/usr/include/expat.h", O_RDONLY|O_NOCTTY) = 4
  
  3172 [pid  3364] stat("/usr/lib/x86_64-linux-gnu/libexpat.so", {st_mode=S_IFREG|0644, st_size=166032, ...}) = 0
  3173 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 7
  3174 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 8
  3175 [pid  3364] stat("/tmp/ccFZziQa.o", {st_mode=S_IFREG|0600, st_size=89008, ...}) = 0
  3176 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 8
  3177 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 9
  
  
  
  
  3172 [pid  3364] stat("/usr/lib/x86_64-linux-gnu/libexpat.so", {st_mode=S_IFREG|0644, st_size=166032, ...}) = 0
  3173 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 7
  3174 [pid  3364] open("/usr/lib/x86_64-linux-gnu/libexpat.so", O_RDONLY) = 8
  3175 [pid  3364] stat("/tmp/ccFZziQa.o", {st_mode=S_IFREG|0600, st_size=89008, ...}) = 0
  3176 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 8
  3177 [pid  3364] open("/tmp/ccFZziQa.o", O_RDONLY) = 9
  </code></pre>
  
  <p>when everything loaded properly why linker throws these errors , any idea ? </p>
  
  <p>I can lookup the function in symbol table:- </p>
  
  <pre><code>$ nm -DC /usr/lib/x86_64-linux-gnu/libexpat.so |grep XML_SetElementHandler 
  000000000000d4a0 T XML_SetElementHandler
  </code></pre>