C++ files stopped compiling - keep getting error: linker command failed with exit code 1 (use -v to see invocation)
C++ files stopped compiling - keep getting error: linker command failed with exit code 1 (use -v to see invocation)
我过去的编译没有问题,我以前写的代码编译得很好,但现在当我尝试使用 Visual Studio 代码编译一个非常简单的 C++ 文件时出现此错误在我的 M1 Mac:
代码:
#include<iostream>
using namespace std;
int main() {
cout << "Hello World" << endl;
return 0;
}
我试过的终端命令(都给出相同的错误):
g++ -std=c++14 test.cpp -o test
g++ -std=c++11 test.cpp -o test
g++ test.cpp -o test
错误:
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)
我尝试删除并重新创建具有不同名称的文件、重新启动 VSC、使用不同的输出文件名,但没有任何改变。
发生这种情况是因为我在编译之前没有保存文件,因此编译器找不到它。
我过去的编译没有问题,我以前写的代码编译得很好,但现在当我尝试使用 Visual Studio 代码编译一个非常简单的 C++ 文件时出现此错误在我的 M1 Mac:
代码:
#include<iostream>
using namespace std;
int main() {
cout << "Hello World" << endl;
return 0;
}
我试过的终端命令(都给出相同的错误):
g++ -std=c++14 test.cpp -o test
g++ -std=c++11 test.cpp -o test
g++ test.cpp -o test
错误:
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)
我尝试删除并重新创建具有不同名称的文件、重新启动 VSC、使用不同的输出文件名,但没有任何改变。
发生这种情况是因为我在编译之前没有保存文件,因此编译器找不到它。