2021년 12월 19일 일요일

CPP 컴파일러 오류 (undefined reference to `__gxx_personality_seh0')

CPP 언어를 오랜만에 컴파일을 하다보니 간혹 빌드 오류가 나는 경우가 있다.

mingw32 컴파일러를 사용하고 있었는데 다음과 같은 오류가 발생하였다.


(.xdata+0x10): undefined reference to `__gxx_personality_seh0'
(.xdata$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
(.xdata$_ZNSt3mapIifSt4lessIiESaISt4pairIKifEEEixERS3_+0x10): undefined reference to `__gxx_personality_seh0'
(.text$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_[_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_]+0xb2): undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
(.xdata$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_+0x10): undefined reference to `__gxx_personality_seh0'
(.text$_ZNSt17_Rb_tree_iteratorISt4pairIKifEEmmEv[_ZNSt17_Rb_tree_iteratorISt4pairIKifEEmmEv]+0x17): undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE10deallocateEPS5_y[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE10deallocateEPS5_y]+0x1c): undefined reference to `operator delete(void*)'
(.text$_ZNSt17_Rb_tree_iteratorISt4pairIKifEEppEv[_ZNSt17_Rb_tree_iteratorISt4pairIKifEEppEv]+0x17): undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv]+0x29): undefined reference to `std::__throw_bad_alloc()'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv]+0x43): undefined reference to `operator new(unsigned long long)'
collect2.exe: error: ld returned 1 exit status


(.text+0x198): undefined reference to `std::ios_base::Init::~Init()'
(.text+0x1c8): undefined reference to `std::ios_base::Init::Init()'
(.xdata+0x1c): undefined reference to `__gxx_personality_seh0'
(.xdata$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
(.xdata$_ZNSt3mapIifSt4lessIiESaISt4pairIKifEEEixERS3_+0x10): undefined reference to `__gxx_personality_seh0'
(.text$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_[_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_]+0xb2): undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
(.xdata$_ZNSt8_Rb_treeIiSt4pairIKifESt10_Select1stIS2_ESt4lessIiESaIS2_EE10_M_insert_INS8_11_Alloc_nodeEEESt17_Rb_tree_iteratorIS2_EPSt18_Rb_tree_node_baseSE_RKS2_RT_+0x10): undefined reference to `__gxx_personality_seh0'
(.text$_ZNSt17_Rb_tree_iteratorISt4pairIKifEEmmEv[_ZNSt17_Rb_tree_iteratorISt4pairIKifEEmmEv]+0x17): undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE10deallocateEPS5_y[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE10deallocateEPS5_y]+0x1c): undefined reference to `operator delete(void*)'
(.text$_ZNSt17_Rb_tree_iteratorISt4pairIKifEEppEv[_ZNSt17_Rb_tree_iteratorISt4pairIKifEEppEv]+0x17): undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv]+0x29): undefined reference to `std::__throw_bad_alloc()'
(.text$_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKifEEE8allocateEyPKv]+0x43): undefined reference to `operator new(unsigned long long)'
collect2.exe: error: ld returned 1 exit status


이건 link 에러이다. VisualC++언어에서는 확장자만 가지고 CPP, C언어 두개 모두 알아서 처리했는데 linux나 GNU c/cpp컴파일러 계열에서는 각각의 컴파일러 이름이 다르다. 그 부분을 간과해서 발생하는 오류였다.

gcc <filename> 을 사용했다면 g++ <filename> 을 사용하기 바랍니다.


댓글 없음:

댓글 쓰기