我已经~/alt
在 Ubuntu 12.04 上使用 GCC-4.6 成功构建并安装了(在前缀下)LLVM-Clang 主干(2012 年 4 月 23 日),然后使用这个 Clang-build 构建并安装了 libc++。当我想使用它时,我必须同时提供-lc++
,-libstdc++
如下所示
/home/per/alt/bin/clang -x c++ -I/home/per/alt/include/v1 -L/home/per/alt/lib -std=gnu++0x -g -Wall ~/f.cpp -lm -lc++ -lstdc++ -lpthread -o f
编译f.cpp
包含
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, const char * argv[]) {
cout << "sxx" << endl;
return 0;
}
如果我省略-lstdc++
,我会收到链接错误
/home/per/alt/include/v1/ostream:989: error: undefined reference to '__cxa_begin_catch'
/home/per/alt/include/v1/ostream:993: error: undefined reference to '__cxa_end_catch'
/home/per/alt/include/v1/ostream:993: error: undefined reference to '__cxa_end_catch'
/tmp/f-4l9mgl.o(.eh_frame+0xd3): error: undefined reference to '__gxx_personality_v0'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compilation exited abnormally with code 1 at Tue Apr 24 13:59:22
不libc++
应该完全替代libstdc++
吗?