The following errors are prompted today when compiling C + + files with your Mac.
1Undefined symbols forArchitecture x86_64:2 "std::__1::__vector_base_common<true>::__throw_length_error () const", referenced from:3void Std::__1::vector<e, std::__1::allocator<e> >::__push_back_slow_path<e const> (E const&)inchmain-8B5A99.O4 "std::terminate ()", referenced from:5___clang_call_terminateinchmain-8B5A99.O6 "operator Delete (void*)", referenced from:7Std::__1::__vector_base<e, std::__1::allocator<e> >::~__vector_base ()inchmain-8B5A99.O8Std::__1::__split_buffer<e, Std::__1::allocator<e>&>::~__split_buffer ()inchmain-8B5A99.O9 "operator new (unsigned long)", referenced from:TenStd::__1::__split_buffer<e, Std::__1::allocator<e>&>::__split_buffer (unsignedLong, unsignedLong, std::__1::allocator<e>&)inchmain-8B5A99.O One "___cxa_begin_catch", referenced from: A___clang_call_terminateinchmain-8B5A99.O - "___cxa_call_unexpected", referenced from: -_maininchmain-8B5A99.O the "___gxx_personality_v0", referenced from: -_maininchmain-8B5A99.O -___cxx_global_array_dtorinchmain-8B5A99.O -void Std::__1::vector<e, std::__1::allocator<e> >::__push_back_slow_path<e const> (E const&)inchmain-8B5A99.O +Dwarf Exception Unwind Info (__eh_frame)inchmain-8B5A99.O - LD: symbol (s) not found forArchitecture x86_64 +Clang:error:linker command failed with exit code1(Use-v to see invocation)
Find the appropriate solution by flipping through the StackOverflow. This occurs because of the C file when the GCC default file is not linked to the C + + standard library at compile time. We can specify the introduction of the C + + standard library in the following ways
gcc main.c-o macin-lstdc++
or use
g++ Main.c-o Main
Reference Link: StackOverflow
Compile C + + error on Mac