2012-04-24 85 views
4

我已經在Ubuntu 12.04上成功使用GCC-4.6並使用此Clang-build成功使用了libC++,並在LLVM-Clang trunk(2012年4月23日)前綴~/alt下安裝。當我想用它,我必須同時提供-lc++-libstdc++如下Clang 3.1 + libC++編譯錯誤

/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++

+2

'main'的簽名是不正確的,我很驚訝它被接受。 – 2012-04-24 11:55:19

+1

Nordlöw,你的cpu arch是什麼?它是手臂嗎? libC++在ARM上沒有實現一些__cxa *:http://libcxxabi.llvm.org/spec.html – osgx 2012-04-24 21:33:15

+0

@osgx不,它是amd64。 – 2012-05-02 10:14:12

回答