r/cpp_questions • u/Pretend-Grocery-1553 • 1d ago
OPEN Unable to fix C++ output
Undefined symbols for architecture arm64:
"_main", referenced from:
<initial-undefines>
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Hi. I've started learning C++ for Arduino and while practicing, I ran my code and the output is saying its a Clang++ error. I downloaded clang as it was recommended by a tutor on youtube,and it works for mark. Even basic print code wont work. Anyway to solve this?
2
Upvotes
14
u/TheRealSmolt 1d ago
You don't have a main function, or your compiler can't find it. We need more info to help; things like code snippets, file structure, etc.
9
u/sharth 1d ago
Hi. You'll need to provide more information to have people help you.
Here's what we're looking for:
clang++ -O3 foo.ccperhaps.Here, you've only provided #4. The other three pieces of information are really vital to actually helping you though.
7
u/jedwardsol 1d ago
Are you saving your file after editing it?
4
u/TomDuhamel 1d ago
What about providing the command that caused that error?
But in itself, the error is pretty clear: What you compiled did not contain a main function.
2
u/Discordbothost 1d ago
Check whether you're building an Arduino sketch or a desktop program. If it's a sketch, use Arduino IDE with your board selected; the Arduino core supplies the entry point. A plain clang++ command leaves out that core, so adding main isn't the right fix for an Arduino sketch.
1
u/turtlesdontcry 1d ago
Definitelt missing main function. Never seen this for anything else. If it is something else I actually wanna know what else it could be. Might learn something new.
1
u/PijanyRuski 1d ago
What Arduino are you using?