我对C++很陌生,当我运行脚本时
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
cout << "Another message";
return 0;
}
在终端cpp test.cpp
中,我得到了以下错误消息:
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
我在Mac上使用clang作为编译器。 文本编辑器是VS Studio代码。 奇怪的是,当我通过扩展“code Runner”在VS Studio代码中运行脚本时,它工作得很好。
我知道还有其他几个类似的问题正在被问,但我无法理解他们是如何解决这个问题的。 谁能给我一些循序渐进的指示? 太谢谢你了!
原来,只需在终端中添加gcc test.cpp-lstdc++
就解决了这个问题。