undefined reference to "operator new" and "operator delete"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tvnaidu
    Contributor
    • Oct 2009
    • 365

    undefined reference to "operator new" and "operator delete"

    I compiled tinyxml files (.cpp files) and when I am linking to create final exe in Linux, I am getting lot of errors saying "undefiend reference" to "operator new" and "delete", any idea?.


    Main.cpp:377: undefined reference to `operator delete[](void*)'
    tinyXML/include/tinystr.h:259: undefined reference to `operator delete[](void*)'
    ../common/tinyXML/include/tinyxml.h:1401: undefined reference to `operator delete[](void*)'
    ../common/tinyXML/include/tinystr.h:259: undefined reference to `operator delete[](void*)'
    /opt/lib/libtinyxml.a(ti nystr.o)(.text+ 0x83):tinyXML/tinystr.h:242: undefined reference to `operator new[](unsigned)'

    /opt/lib/libtinyxml.a(ti nystr.o)(.text+ 0xb7):tinyXML/tinystr.h:259: undefined reference to `operator delete[](void*)'

    /opt/lib/libtinyxml.a(ti nystr.o)(.text+ 0x14f):tinyXML/tinystr.h:242: undefined reference to `operator new[](unsigned)'
    /opt/lib/libtinyxml.a(ti nystr.o)(.text+ 0x19a):tinyXML/tinystr.h:259: undefined reference to `operator delete[](void*)'
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    I don`t know anything about linux but it sounds as though you are missing the include file which defines the new and delete operators, like #include<iostre am> in the environment I work in. I`ll be interested to see what the experts say.

    Comment

    • tvnaidu
      Contributor
      • Oct 2009
      • 365

      #3
      I did include #include <iostream> in all .cpp files, but it didn't help, any other clue?.

      Comment

      • tvnaidu
        Contributor
        • Oct 2009
        • 365

        #4
        Found the issue: I need to pass -lstdc++ during linking, those errors gone, couple of more for shared libs.

        Comment

        Working...