我是编码新手,我试图在本学期开始之前为 C++ 设置我的 VS Code,但我不知道我做错了什么?我写了一个简单的 hello world 代码来测试它,但我无法让它运行。
#include <iostream>
int main() {
std::cout << "Hello, World!" <<;
return 0;
}
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试在互联网上查找它,但似乎没有任何结果,或者也许我太缺乏经验,无法理解。
当我运行代码时,我收到此错误消息
main.cpp: In function 'int main()':
main.cpp:4:34: error: expected primary-expression before ';' token
4 | std::cout << "Hello, World!" <<;
| ^
** Process exited - Return Code: 1 **
我认为问题是你添加了一个“<<" on line 4 that was unnecessary.
试试这个吧
#include <iostream>
int main()
std::cout << "Hello World";
return 0;
}