1,
<span style="color:#ff0000;">test.cpp:(.text+0xc): undefined reference to `std::cout'
test.cpp:(.text+0x22): undefined reference to `std::ostream::operator<<(int)'
test.cpp:(.text+0x2a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
test.cpp:(.text+0x32): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
test.cpp:(.text+0x4f): undefined reference to `__cxa_allocate_exception'
test.cpp:(.text+0x6e): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x82): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x94): undefined reference to `std::runtime_error::runtime_error(std::string const&)'</span>
这是由于clang编译时默认不是标准的c++库,解决的办法就是在clang编译的选项中加上-lstdc++,用来指明clang编译时使用标准的c++库