我正在使用Xcode 5.1.1运行MacOS X Mavericks,包括命令行工具.我正在使用Xcode提供的clang ++编译简单的C++程序,版本信息是:Apple LLVM版本5.1(clang-503.0.40)(基于LLVM 3.4svn)
我发现如果我尝试运行以下命令
clang ++ -o hello.out hello.cpp
我收到以下错误:
Undefined symbols for architecture x86_64:
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in hello-2ad0da.o
"std::ios_base::Init::~Init()", referenced from:
___cxx_global_var_init in hello-2ad0da.o
"std::cout", referenced from:
_main in hello-2ad0da.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in hello-2ad0da.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
如果我将命令更改为
clang ++ -o hello.out -stdlib = libstdc …