Compile C + + error on Mac

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.