0

I'm having a weird error. I'm trying to use the Map library, and doing so is breaking my code.

I define my map thusly:

map<int, int> myMap;

And that breaks my code. If I comment it out, everything runs as expected. My code isn't super complicated or doing anything weird either.

The exact error is:

/tmp/ccapuHUe.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, int>>>::decallocate(std::_Rb_tree_node<std::pair<int const, int>>*, unsigned int)`:
program.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKiiEEE10deallocateEPS5_j[__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, int>>>::deallocate(std::_Rb_tree_node<std::pair<int const, int>>*, unsigned int)]+0xd: undefined reference to `operator delete(void*)`
/tmp/ccapuHue.0:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0`
collect2: ld returned 1 exit status

I have no idea what any of that means. I'm not even using other map functions, just the initialization (I'll add the other functions once I sort this out).

My gcc is version 4.3.6, if that matters.

Just to be certain, I tested the following code:

#include <map>
int main(int argc, char* argv[])
{
    std::map<int, int> myMap;
    return 0;
}

And that doesn't work either! I get the same error (Aside from the .text location)!

Am I doing something wrong? The Documentation for C++ Map Constructors show that this is a valid construct. Is something wrong with my computer or something?

Boom
  • 2,465
  • 4
  • 19
  • 21
  • 1
    Does this happen when compiling with gcc instead of g++, or am I thinking of something else? – chris Apr 03 '15 at 17:52
  • I don't get it... g++ worked, gcc didn't. Why? – Boom Apr 03 '15 at 17:53
  • 2
    @Boom: gcc is a C compiler (and linker), so it won't link with the C++ library. Use a C++ compiler like g++ for C++. – Mike Seymour Apr 03 '15 at 17:54
  • [This seems pretty similar](http://stackoverflow.com/questions/203548/undefined-symbol-gxx-personality-v0-on-link?lq=1) – chris Apr 03 '15 at 17:56
  • I've never had this problem before. How strange. I'll flag this as a duplicate linking the other question. – Boom Apr 03 '15 at 17:56

0 Answers0