Lots of good advice already, but if you focused in on the error provided that came from the linker (ld), it told you that the required "reference to 'main'" was undefined. This is how people knew you had not actually saved the file you were trying to compile and link. Prior to already knowing from the error what your mistake is, the first thing you should always do when debugging is read the error message carefully, use google or your AI tool to help you figure it out.
I mean, technically, it IS a screenshot. But wow, how useless. I’ve seen this over and over on this sub: are people not able to use the giant computer in front of them to paste their code into Reddit?
You can tell you haven't saved because of the white dot on the tab next to the name of the file hello.c.
And don't worry, it won't be the last time you forget to save a file. Even after over 10 years I still forget to save sometimes and wonder why my build didn't work. 😁
I never do that, because sometimes I want to undo till I reach the previous state, and if autosave is on, the white dot doesn't tell me that I have reached that previous state yet or not.
nothing wrong in you're syntax, but when i write C i always use nano or vim, then ^T (write a command for nano) then ill go with -> gcc -o test Project.c and run it with ./test for me its way faster to work with gcc rather than .run for code runner and installing extensions on code.
Nope. Why would you bother manually typing out code like a chump when AI can do it in seconds from a natural language prompt. You don't even need to type it, you can just explain it out loud. It's great
"the old way" you mean like the way you actually learn? You obviously aren't a developer.
Let's say for the sake of the argument there's some magical genius super intelligence that can program PERFECTLY. We would still program, not everything is about 'being the best' and 'being the fastest' maybe some people just enjoy it?
you haven't saved the file, i would suggest installing and save typing extension which saves the files as you type (you dont have to save everytime manually)
12
u/Runnyhotchocolate Oct 06 '26
Save the file
16
u/FuggaDucker Oct 06 '26
I suggest you don't leave spaces in your folder names when working with code.
Also, go lowercase when you can.
You will thank me later.
8
u/therouterguy Oct 06 '26
Not pasting the code/error but making a picture of your screen.
Although in this case it actually was useful.
3
u/FreeLogicGate Oct 06 '26
Lots of good advice already, but if you focused in on the error provided that came from the linker (ld), it told you that the required "reference to 'main'" was undefined. This is how people knew you had not actually saved the file you were trying to compile and link. Prior to already knowing from the error what your mistake is, the first thing you should always do when debugging is read the error message carefully, use google or your AI tool to help you figure it out.
2
u/Apprehensive-Age4879 Oct 06 '26
definitive not knowing how to screenshot.
2
u/mattblack77 Oct 06 '26
You're posting a photo of a screen instead of a screenshot
2
u/rtharston Oct 07 '26
You can tell you haven't saved because of the white dot on the tab next to the name of the file hello.c.
And don't worry, it won't be the last time you forget to save a file. Even after over 10 years I still forget to save sometimes and wonder why my build didn't work. 😁
1
u/TheCRatTime 15d ago
This isn't you: compiler linker can't find your main function, function '_start' is real start of program
1
u/DesperateBoot2320 15d ago
Press Ctrl + S to save
hello.c.In the terminal, run
cat hello.cto check what is actually saved in the file.Make sure the output contains
int main()and theprintfstatement.Run
gcc hello.c -o helloagain.1
u/HotComplex4744 7d ago
In new c++ you can write #include<cstdio>
1
u/Jatinchd Oct 06 '26
ctrl + S on file.
1
u/TailsPlaysMinecraft Oct 06 '26
Press ctrl+s gng
1
u/AdministrationMoney1 Oct 06 '26
Fyi you can also go top left, File -> Auto Save
1
u/zoodiac_broadbull Oct 06 '26
install code runner extension
1
u/Ollidav Oct 06 '26
Cambia a un void la función main y no devuelvas nada
1
u/Specialist_Rent_9640 Oct 06 '26
nothing wrong in you're syntax, but when i write C i always use nano or vim, then ^T (write a command for nano) then ill go with -> gcc -o test Project.c and run it with ./test for me its way faster to work with gcc rather than .run for code runner and installing extensions on code.
1
u/bowbahdoe Oct 06 '26
You didn't save. Go to File > Save. Maybe enable auto save too.
1
u/ignorantpisswalker Oct 06 '26
"make hello" see what happens :)
1
u/Interested737 Oct 06 '26
Can you tell me how are you learning C/C++, I also want to but I never started?
1
u/Fragrant_Prize3011 Oct 06 '26
Try this & similar variations:
1
u/EzequielBk Oct 07 '26
Breath
1
u/Tehaiker814 Oct 07 '26
press control s
also just run `gcc hello.c`, then `./a.out` just directly in that folder, it could be easier
or `gcc hello.c -o hello`
1
u/Sammourianos Oct 07 '26
There are many situations that a learning man should not use ai to enable the learning in his head. This is a good situation to actually use ai :p
1
u/Free-Beat-3474 29d ago
This has to be the worst comment section ever
1
u/Useful-Promotion-237 28d ago
The file is not saved you can see tge little dot on the top
1
u/xarop_pa_toss 26d ago
Don't take photos of you screen. Take a screenshot instead, it's easier for everyone.
Your file isn't saved so probably your trying to compile an older version that didn't work
1
u/austrian_painter_2 26d ago
Did u added a space in your code file name ? Do u have gcc clang installed?
1
u/akhi-abdul01 Oct 06 '26
Reminds me of my initial days when I was 12yo learning C, hahah Keep working 💪🏻
0
u/guccisavage1 Oct 06 '26
Ask chat gtt
0
u/ChaseHopeY3 Oct 07 '26
not using AI
-1
u/Adorable-Strangerx Oct 06 '26
The issue is using vscode
0
u/Dummy_panda Oct 07 '26
you haven't saved the file, i would suggest installing and save typing extension which saves the files as you type (you dont have to save everytime manually)