Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

c++ - 如何在macOS中使用(链接)调试版本的libc ++?(How to use (link) debug version of libc++ in macOS?)

I want to enable debug version of libc++ in macOS, so I define _LIBCPP_DEBUG=1 in cxx_build_flags [Debug Version of libC++] , but unable to link debug function of libc++ .

(我想在macOS中启用libc++调试版本,因此我在cxx_build_flags [libC ++的调试版本]中定义了_LIBCPP_DEBUG=1 ,但是无法链接libc++调试功能。)

I guess there is only release version of libc++ in my system, so how can I get the debug version of libc++ in macOS

(我猜我的系统中只有libc++发行版,所以如何在macOS中获得libc++的调试版)

Undefined symbols for architecture x86_64:
"std::__1::__libcpp_db::__decrementable(void const*) const", referenced from:
  void std::__1::__nth_element<std::__1::__debug_less<std::__1::__less<float, float> >&, std::__1::__wrap_iter<float*> >(std::__1::__wrap_iter<float*>, std::__1::__wrap_iter<float*>, std::__1::__wrap_iter<float*>, std::__1::__debug_less<std::__1::__less<float, float> >&)
  ask by Jack chen translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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中看到了相同的问题,但仍然没有答案。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...