声明矢量地图时出错

时间:2013-09-25 05:16:59

标签: c++ vector map stl

我正在尝试声明矢量地图,但是它给出了错误。

我的代码:

int main() {

    map <int, vector<int> > ele;

return 0;
}

错误:

In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, std::vector<int, std::allocator<int> > > > >::deallocate(std::_Rb_tree_node<std::pair<int const, std::vector<int, std::allocator<int> > > >*, unsigned int)':
q2.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKiSt6vectorIiSaIiEEEEE10deallocateEPS8_j[__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, std::vector<int, std::allocator<int> > > > >::deallocate(std::_Rb_tree_node<std::pair<int const, std::vector<int, std::allocator<int> > > >*, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
/tmp/ccjbk0JX.o: In function `__gnu_cxx::new_allocator<int>::deallocate(int*, unsigned int)':
q2.cpp:(.text._ZN9__gnu_cxx13new_allocatorIiE10deallocateEPij[__gnu_cxx::new_allocator<int>::deallocate(int*, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
/tmp/ccjbk0JX.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
/tmp/ccjbk0JX.o:(.eh_frame+0xa7): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

我无法理解这个错误。 请帮忙。

1 个答案:

答案 0 :(得分:0)

当您尝试使用gcc编译C ++代码时,通常会出现该错误,请尝试使用g ++。 如果仍然失败,请尝试传递-lstdc ++(例如g ++ main.c -lddc ++)。