Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My main.cpp: https://imgur.com/a/wiARur9 My C++ file is fine in Xcode but produces the following error in g++: gcc -std=c++11 main.cpp -o main.exe Undefined symbols for

My main.cpp: https://imgur.com/a/wiARur9

My C++ file is fine in Xcode but produces the following error in g++:

gcc -std=c++11 main.cpp -o main.exe

Undefined symbols for architecture x86_64:

"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:

std::__1::ctype const& std::__1::use_facet >(std::__1::locale const&) in main-914431.o

"std::__1::ios_base::getloc() const", referenced from:

std::__1::basic_ios >::widen(char) const in main-914431.o

"std::logic_error::logic_error(char const*)", referenced from:

std::length_error::length_error(char const*) in main-914431.o

"std::length_error::~length_error()", referenced from:

std::__1::__throw_length_error(char const*) in main-914431.o

"std::__1::basic_string, std::__1::allocator >::__init(unsigned long, char)", referenced from:

std::__1::basic_string, std::__1::allocator >::basic_string(unsigned long, char) in main-914431.o

"std::__1::basic_string, std::__1::allocator >::push_back(char)", referenced from:

std::__1::basic_istream >& std::__1::getline, std::__1::allocator >(std::__1::basic_istream >&, std::__1::basic_string, std::__1::allocator >&, char) in main-914431.o

"std::__1::basic_string, std::__1::allocator >::~basic_string()", referenced from:

_main in main-914431.o

std::__1::ostreambuf_iterator > std::__1::__pad_and_output >(std::__1::ostreambuf_iterator >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-914431.o

"std::__1::basic_istream >::sentry::sentry(std::__1::basic_istream >&, bool)", referenced from:

std::__1::basic_istream >& std::__1::getline, std::__1::allocator >(std::__1::basic_istream >&, std::__1::basic_string, std::__1::allocator >&, char) in main-914431.o

"std::__1::basic_ostream >::sentry::sentry(std::__1::basic_ostream >&)", referenced from:

std::__1::basic_ostream >& std::__1::__put_character_sequence >(std::__1::basic_ostream >&, char const*, unsigned long) in main-914431.o

"std::__1::basic_ostream >::sentry::~sentry()", referenced from:

std::__1::basic_ostream >& std::__1::__put_character_sequence >(std::__1::basic_ostream >&, char const*, unsigned long) in main-914431.o

"std::__1::cin", referenced from:

_main in main-914431.o

"std::__1::cout", referenced from:

_main in main-914431.o

"std::__1::ctype::id", referenced from:

std::__1::ctype const& std::__1::use_facet >(std::__1::locale const&) in main-914431.o

"std::__1::locale::~locale()", referenced from:

std::__1::basic_ios >::widen(char) const in main-914431.o

"std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:

std::__1::basic_ostream >& std::__1::__put_character_sequence >(std::__1::basic_ostream >&, char const*, unsigned long) in main-914431.o

"std::__1::ios_base::clear(unsigned int)", referenced from:

std::__1::ios_base::setstate(unsigned int) in main-914431.o

"std::terminate()", referenced from:

___clang_call_terminate in main-914431.o

"typeinfo for std::length_error", referenced from:

std::__1::__throw_length_error(char const*) in main-914431.o

"vtable for std::length_error", referenced from:

std::length_error::length_error(char const*) in main-914431.o

NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

"operator delete(void*)", referenced from:

std::__1::_DeallocateCaller::__do_call(void*) in main-914431.o

"operator new(unsigned long)", referenced from:

std::__1::__libcpp_allocate(unsigned long, unsigned long) in main-914431.o

"___cxa_allocate_exception", referenced from:

std::__1::__throw_length_error(char const*) in main-914431.o

"___cxa_begin_catch", referenced from:

___clang_call_terminate in main-914431.o

std::__1::basic_istream >& std::__1::getline, std::__1::allocator >(std::__1::basic_istream >&, std::__1::basic_string, std::__1::allocator >&, char) in main-914431.o

std::__1::basic_ostream >& std::__1::__put_character_sequence >(std::__1::basic_ostream >&, char const*, unsigned long) in main-914431.o

"___cxa_end_catch", referenced from:

std::__1::basic_istream >& std::__1::getline, std::__1::allocator >(std::__1::basic_istream >&, std::__1::basic_string, std::__1::allocator >&, char) in main-914431.o

std::__1::basic_ostream >& std::__1::__put_character_sequence >(std::__1::basic_ostream >&, char const*, unsigned long) in main-914431.o

"___cxa_free_exception", referenced from:

std::__1::__throw_length_error(char const*) in main-914431.o

"___cxa_rethrow", referenced from:

std::__1::basic_istream >& std::__1::getline, std::__1::allocator >(std::__1::basic_istream >&, std::__1::basic_string, std::__1::allocator >&, char) in main-914431.o

"___cxa_throw", referenced from:

std::__1::__throw_length_error(char const*) in main-914431.o

"___gxx_personality_v0", referenced from:

_main in main-914431.o

std::__1::__deque_base >::~__deque_base() in main-914431.o

std::__1::__deque_base >::clear() in main-914431.o

std::__1::__deque_base >::begin() in main-914431.o

std::__1::__deque_base >::end() in main-914431.o

std::__1::allocator::deallocate(char*, unsigned long) in main-914431.o

std::__1::__split_buffer >::~__split_buffer() in main-914431.o

...

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions