Menu

undefined reference to TiXmlString::nullrep_

Drew Vogel
2005-11-20
2013-05-20
  • Drew Vogel

    Drew Vogel - 2005-11-20

    I use Debian Linux. I used the Makefile with the options DEBUG=YES, PROFILE=YES, TINYXML_USE_STL=YES. I took the 4 resulting object files (tinystr.o, tinyxml.o, tinyxmlerror.o, and tinyxmlparser.o) and created a library with the command `ar cr libtinyxml.a tinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o`. I put the library in /usr/local/lib and the two .h files (tinystr.h and tinyxml.h) in /usr/local/include/tinyxml.

    I #include both .h files in my .cpp file. Everything compiles fine, but I get the error (from ld, run by g++ 4.0.3) "In function TiXmlString::quit() /usr/.../tinystr.h:240: undefined reference to TiXmlString::nullrep_"

    Looking at tinystr.h, nullrep_ is in fact used before it is declared. It is used, among other places, on line 240 (as the error message says) but it is not declared until line 249. This begs the question, why in the world is the implementation in the .h file anyway?

     
    • Yves Berquin

      Yves Berquin - 2005-11-20

      tinystr shouldn't be compiled if you declare TINYXML_USE_STL.

      The whole point is to replace the functionnality of std::string for those programmers who can't afford to use the Standard Template Library.

       
    • Drew Vogel

      Drew Vogel - 2005-11-21

      Ah. Thanks.

      Perhaps that "detail" should be added to the Makefile?

       
    • Lee Thomason

      Lee Thomason - 2005-11-22

      I think this can only happen if you compile the library with TIMXL_USE_STL=NO and compile the app with TIXML_USE_STL=YES. The entire tinystr should be "compiled out" with the correct TIXML_USE_STL setting.

      Is that what happened? Or did a bug slip in to the tinystring code?

      thanks,
      lee

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.