I am using a MacBook Air M2, and I am new this machine. I found out that there is Clang on MacBook which is directly taken in use by default for C and C++ code in MacBook. But my system is having one issue or kind of issue, when I compile code with a simple line like:
gcc 1931D.cpp -o 1931D
它给我留下了一个错误:
Undefined symbols for architecture arm64:
"std::logic_error::logic_error(char const*)", referenced from:
std::length_error::length_error[abi:ue170006](char const*) in 1931D-f28fab.o
"std::length_error::~length_error()", referenced from:
std::__1::__throw_length_error[abi:ue170006](char const*) in 1931D-f28fab.o
"std::bad_array_new_length::bad_array_new_length()", referenced from:
std::__throw_bad_array_new_length[abi:ue170006]() in 1931D-f28fab.o
"std::bad_array_new_length::~bad_array_new_length()", referenced from:
std::__throw_bad_array_new_length[abi:ue170006]() in 1931D-f28fab.o
"std::__1::basic_istream<char, std::__1::char_traits<char>>::operator>>(long long&)", referenced from:
_main in 1931D-f28fab.o
solve() in 1931D-f28fab.o
solve() in 1931D-f28fab.o
solve() in 1931D-f28fab.o
solve() in 1931D-f28fab.o
"std::__1::cin", referenced from:
_main in 1931D-f28fab.o
solve() in 1931D-f28fab.o
solve() in 1931D-f28fab.o
"std::terminate()", referenced from:
___clang_call_terminate in 1931D-f28fab.o
"typeinfo for std::length_error", referenced from:
std::__1::__throw_length_error[abi:ue170006](char const*) in 1931D-f28fab.o
"typeinfo for std::bad_array_new_length", referenced from:
std::__throw_bad_array_new_length[abi:ue170006]() in 1931D-f28fab.o
"vtable for std::length_error", referenced from:
std::length_error::length_error[abi:ue170006](char const*) in 1931D-f28fab.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"operator delete(void*)", referenced from:
std::__1::allocator<long long>::deallocate[abi:ue170006](long long*, unsigned long) in 1931D-f28fab.o
void std::__1::__libcpp_operator_delete[abi:ue170006]<void*>(void*) in 1931D-f28fab.o
"operator new(unsigned long)", referenced from:
std::__1::allocator<long long>::allocate[abi:ue170006](unsigned long) in 1931D-f28fab.o
void* std::__1::__libcpp_operator_new[abi:ue170006]<unsigned long>(unsigned long) in 1931D-f28fab.o
"___cxa_allocate_exception", referenced from:
std::__1::__throw_length_error[abi:ue170006](char const*) in 1931D-f28fab.o
std::__throw_bad_array_new_length[abi:ue170006]() in 1931D-f28fab.o
"___cxa_begin_catch", referenced from:
___clang_call_terminate in 1931D-f28fab.o
"___cxa_call_unexpected", referenced from:
std::__1::vector<long long, std::__1::allocator<long long>>::max_size() const in 1931D-f28fab.o
std::__1::vector<long long, std::__1::allocator<long long>>::__base_destruct_at_end[abi:ue170006](long long*) in 1931D-f28fab.o
std::__1::allocator<long long>::deallocate[abi:ue170006](long long*, unsigned long) in 1931D-f28fab.o
"___cxa_free_exception", referenced from:
std::__1::__throw_length_error[abi:ue170006](char const*) in 1931D-f28fab.o
"___cxa_throw", referenced from:
std::__1::__throw_length_error[abi:ue170006](char const*) in 1931D-f28fab.o
std::__throw_bad_array_new_length[abi:ue170006]() in 1931D-f28fab.o
"___gxx_personality_v0", referenced from:
/private/var/folders/pt/csddh2cd0fq4krbz3vjkgf7m0000gn/T/1931D-f28fab.o
**ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)**
但是,当我使用以下代码时,它会进行罚款,因为我指的是C++文档,我是猜测。
gcc 1931D.cpp -o 1931D -lstdc++
我的PC为什么会发生这种情况? 是否有办法避免这种情况?
另外,我如何在MacBook Air M2中重新确定整个C++或汇编者?
I Trial gcc 1931D.cpp -o 1931D -lstdc++
, and it s working penalty, but, why do I must written “-lstdc++”? 它还在使用视觉演播室法和使用C++推广法方面造成了问题。