I've had no problems compiling in the past, and code that I wrote previously is compiling fine, but it is now giving this error when I try to compile a very simple C++ file using Visual Studio Code on my M1 Mac:
Code:
#include<iostream>
using namespace std;
int main() {
cout << "Hello World" << endl;
return 0;
}
The terminal commands I've tried (all give same error):
g++ -std=c++14 test.cpp -o test
g++ -std=c++11 test.cpp -o test
g++ test.cpp -o test
Error:
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)
I've tried to delete and re-create the file with different names, restarting VSC, using different output file names and nothing changes this.