【发布时间】:2022-12-12 08:51:55
【问题描述】:
在 visual studio code 上,在 2020 I7 Mac 上,在任何 c++ 程序(这是我检查过的唯一一个公平的程序)上,我收到此错误:
[Running] cd "/Users/creaturesceptique/projects/helloworld/" && g++ Wontwork.cpp -o
Wontwork && "/Users/creaturesceptique/projects/helloworld/"Wontwork
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)
[Done] exited with code=1 in 0.1 seconds
我的 C++ 代码是:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World" << std::endl;
return 0;
}
我对此很陌生,所以请容忍我的愚蠢......
顺便说一句,我正在使用基本的 Code Runner 和 Microsoft c/c++ 扩展。
【问题讨论】:
-
代码看起来不错,很可能是 VS Code [缺乏] 配置。你是如何安装你的编译器的?
-
C++ 不是脚本语言。
-
似乎 VS Code 默认设置是不是在编译之前将文件保存到磁盘。
标签: c++ macos compiler-errors