我想在 macOS 中启用 libc++
的调试版本,因此我在 cxx_build_flags
[Debug Version of libC++] 中定义 _LIBCPP_DEBUG=1
,
但无法链接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
文件 - 在您的项目中包含/编译/链接
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?&path[]=libcxx&path[]=include&path[]=__config我发现提交 https://github.com/llvm/llvm-project/commit/25977548aa5ad7cfe45a17e4ba136abfa4613b96#diff-0a85f740cd20254bc3bb03975c89d93a
- 该提交的
debug.cpp
位于 https://github.com/llvm/llvm-project/blob/25977548aa5ad7cfe45a17e4ba136abfa4613b96/libcxx/src/debug.cpp
关于c++ - 如何在 macOS 中使用(链接)调试版本的 libc++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49508069/