MacOS中的LIBC 的如何使用(链接)调试版本
How to use (link) debug version of libc++ in macOS?
我想在macOS中启用 libc++
的调试版本,所以我在 cxx_build_flags
中定义了 _LIBCPP_DEBUG=1
[libc 的调试版本],但无法链接libc++
的调试功能。我想我的系统中只有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> >&)
我想我可以工作!
所以我采取的步骤,
- 检查您的工具链
__config
是否为_LIBCPP_VERSION
的值。 - 浏览设置该版本的提交的源回购
- 从该提交中,找到
debug.cpp
文件 - 包括/compile/link
debug.cpp
与您的项目(并记住设置_LIBCPP_DEBUG=1
(。
对我来说,这些步骤的中间结果为(使用Catalina,Xcode版本11.3.1(
-
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config
在版本8000
- 在https://github.com/llvm/llvm-project/commits/main?&ppath [] = libcxx&amp;path []///github.com/llvm/llvm-project/commit/25977548AA5AD7CFE45A17E4BA136ABFA4613B9B96#DIFF-0A85F740CD20222220254BBC3BBBBBBBBBBBB03975C89D93A3A3A3A3AA >
- 该提交的
debug.cpp
在https://github.com/llvm/llvm/llvm-project/blob/259777548aaaaaa5ad7cfe45a17e4ba136abfa4613b9b966666666666666666/libcxxxx/srcx/src/src/deebug.cpp
我尝试在没有更多详细信息的情况下重新激活此线程。
我也有同样的问题。这很容易复制:
#include <string>
int main()
{
std::string name;
return 0;
}
然后与:
编译clang++ -D_LIBCPP_DEBUG=1 main.cpp
我们获得:
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)
,如果我使用brew的g++-9
Providen(真正的G 而不是伪装的Apple Clang编译器(,它将编译并完美运行。
忘记使用libc 的调试模式,它是唯一的解决方案吗?
nb:我在https://forums.developer.apple.com/thread/99194中看到了同样的问题仍然没有答案。
相关文章:
- 无法使函数公开。获取:"LNK2005"错误。如何调试链接器错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 错误 VSP1011:无法获取调试信息.与 /配置文件链接器开关链接
- 如何将libc++与调试符号链接起来?
- MacOS中的LIBC 的如何使用(链接)调试版本
- Vscode C++调试使用 cl.exe 和 / 链接构建的代码.exe - 调试器不附加
- 在调试模式下使用 Visual C++ 2017 针对 XP (v141_xp) 链接 ODBCCP32.lib 时LN
- Makefile和QT5:链接QT5与调试符号
- 使用链接列表实现堆栈,调试断言失败
- OpenSSL 动态调试库链接
- 使用GDB中的多个链接文件进行调试
- Visual Studio 2010 默认属性表似乎在调试和发布配置下都链接在一起,这是怎么回事?
- 调试字体链接
- 静态链接系统库,libc,pthreads,以帮助调试
- 如何调试STL/C++的GCC/LD链接过程
- 警告LNK4206:找不到预编译类型信息; 未链接或覆盖;链接对象,就好像没有调试信息一样
- C++ 中编译器、链接器和调试器之间的区别
- 提升线程链接在 Netbeans 7.1 调试/测试会话中失败
- 尝试链接 boost::文件系统以调试 MSVC11 项目时出现链接器错误
- 如何通知调试器运行时链接的 DLL 文件的位置