0

I have been trying to fix this error for days now. Every time I try to run code in cpp on Mac I get this error message

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'm thinking it has something to do with either the linker or the clang file, let me know what I need to do to fix this

-- I just fixed this, it was a problem with my settings, thank you.

rioV8
  • 24,506
  • 3
  • 32
  • 49
NSNW
  • 1
  • 1
  • Implement an `int main()`. Also remember that in VSCode the default behavior is to build only the active file into your executable. If you have more than 1 source file you need to follow the instructions in the VSCode documentation on how to have it compile all of your files in the same folder. Or you need to switch to use CMake or a Makefile as your build task. – drescherjm Sep 07 '21 at 14:32
  • #include using namespace std; int main() { int x = 9; cout << x; return 0; }I have already implemented an int main(), I have only been compiling simple cout codes and it keeps giving the same error code – NSNW Sep 07 '21 at 14:43
  • 1
    have you saved your file before compiling? How are you compiling your code? Please [edit](https://stackoverflow.com/posts/69089995/edit) any clarifications into your question – Alan Birtles Sep 07 '21 at 14:44
  • Look at the compile commands in the terminal. Verify that the correct file is used. Also use some other editor to verify that the file contains the contents that you expect. I also suspect that you didn't save your file before compiling. – drescherjm Sep 07 '21 at 14:47

0 Answers0