I try to reactivate this thread without an answer with more details.
(我尝试重新激活此线程,而没有更多详细信息的答案。)
I have the same issue.
(我有同样的问题。)
This is very easy to reproduce: (这很容易重现:)
#include <string>
int main()
{
std::string name;
return 0;
}
and then compile with:
(然后编译:)
clang++ -D_LIBCPP_DEBUG=1 main.cpp
We obtain:
(我们获得:)
Undefined symbols for architecture x86_64:
"std::__1::__libcpp_db::__insert_c(void*)", referenced from:
void std::__1::__libcpp_db::__insert_c<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in main-7ff3c5.o
"std::__1::__libcpp_db::__erase_c(void*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() in main-7ff3c5.o
"std::__1::__c_node::~__c_node()", referenced from:
std::__1::_C_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~_C_node() in main-7ff3c5.o
"std::__1::__get_db()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string() in main-7ff3c5.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() in main-7ff3c5.o
"typeinfo for std::__1::__c_node", referenced from:
typeinfo for std::__1::_C_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in main-7ff3c5.o
"vtable for std::__1::__c_node", referenced from:
std::__1::__c_node::__c_node(void*, std::__1::__c_node*) in main-7ff3c5.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And if I use g++-9
providen by brew (a real g++ not a disguised Apple Clang compiler), it compiles and runs perfectly.
(而且,如果我使用brew的g++-9
Providen(真正的g ++而不是伪装的Apple Clang编译器),它将编译并完美运行。)
Forgetting to use debug mode of libc++, is it the only solution?
(忘记使用libc ++的调试模式,这是唯一的解决方案吗?)
NB: I saw the same question in https://forums.developer.apple.com/thread/99194 and still no answer.
(注意:我在https://forums.developer.apple.com/thread/99194中看到了相同的问题,但仍然没有答案。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…