【发布时间】:2011-10-24 09:48:51
【问题描述】:
第一对太长了,无法参考。当我尝试使用来自 SVN 的 clang 和 libc++ 编译 clang++ -stdlib=libc++ ../main.cc ... 时出现此错误。
error: undefined reference to 'typeinfo for char const*'
error: undefined reference to '__cxa_allocate_exception'
error: undefined reference to '__cxa_throw'
/tmp/cc-pbn00y.o:../main.cc:function std::__1::deque<double, std::__1::allocator<double> >::__add_back_capacity(): error: undefined reference to '__cxa_begin_catch'
/tmp/cc-pbn00y.o:../main.cc:function std::__1::deque<double, std::__1::allocator<double> >::__add_back_capacity(): error: undefined reference to '__cxa_rethrow'
/tmp/cc-pbn00y.o:../main.cc:function std::__1::deque<double, std::__1::allocator<double> >::__add_back_capacity(): error: undefined reference to '__cxa_end_catch'
/tmp/cc-pbn00y.o(.eh_frame+0xbd3): error: undefined reference to '__gxx_personality_v0'
解决方案:感谢其中一个答案,我知道解决方案。 libc++ 不能像 libstdc++ 一样单独使用,它必须与 libc++abi 一起链接。不过libc++abi还没有完成,所以目前使用libc++似乎有点不完整,但完成后还是我的首选。
2012 年 5 月 26 日更新: libc++abi 现在已完成 C++,我一直在成功使用 clang++,如下所示 clang++ -std=c++11 -stdlib=libc++ -lc++abi。
【问题讨论】:
-
所有提到的未定义引用都在 libc++abi 中定义:abi-laboratory.pro/…
标签: c++ clang std undefined-reference libc++