C++ 编译c++;与“铿锵”的新手

C++ 编译c++;与“铿锵”的新手,c++,C++,我在教程中找到了这段代码 边做边编译 clang -x c++ tutorial.cpp 错误 /tmp/tutorial-aa5f7a.o:在函数“main”中: tutorial.cpp:(.text+0xa):对“std::cout”的未定义引用 tutorial.cpp:(.text+0x34):对'std::ostream::operator的未定义引用使用clang++tutorial.cpp-如果您只想使用-c编译源文件,-x c++非常有用,但是如果您还想将应用程序链接到可执

我在教程中找到了这段代码

边做边编译

clang -x c++ tutorial.cpp
错误
/tmp/tutorial-aa5f7a.o:在函数“main”中:
tutorial.cpp:(.text+0xa):对“std::cout”的未定义引用

tutorial.cpp:(.text+0x34):对'std::ostream::operator的未定义引用使用
clang++tutorial.cpp
-如果您只想使用
-c
编译源文件,
-x c++
非常有用,但是如果您还想将应用程序链接到可执行文件中,你想<代码> CLAN<代码>知道你正在连接C++应用程序,并将C++库添加到链接命令(如果你想看到什么是代码> Cuang< <代码> >,添加<代码> -v< /Cord>选项。< /P>
apt-get install clang
clang -x c++ tutorial.cpp
/tmp/tutorial-aa5f7a.o: In function `main':
tutorial.cpp:(.text+0xa): undefined reference to `std::cout'
tutorial.cpp:(.text+0x34): undefined reference to `std::ostream::operator<<(int)'
tutorial.cpp:(.text+0x3a): 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> >&)'
tutorial.cpp:(.text+0x46): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/tutorial-aa5f7a.o: In function `__cxx_global_var_init':
tutorial.cpp:(.text.startup+0x13): undefined reference to `std::ios_base::Init::Init()'
tutorial.cpp:(.text.startup+0x19): undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)