Hi everyone
I am a beginner having doubt in the set-up
Downloaded visual studio code, Mingw(from source code, minimalist gnu for window download), code runner
Added the bin folder of Mingw to user environment path.
Able to see gcc version in the terminal.
When trying to execute simple c script(hello world) facing issue in getting the output
[Running] cd "c:\User\sriha\Documents\c_code" && gcc third.c -o third && "c:\User\sriha\Documents\c_code"third
Error message: c:/mingw/bin ../lib/gcc/mingw32/6.3.0/ ../../../libmingw32.a(main.o):(.text.startup+0xa0) : undefined reference to WinNain@16' collect2.exe: error: I'd returned 1 exit status
#About setting up visual studio code for c
31 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Could you post your hello world code? Make sure you saved your file before running
main(){
printf("hello world");
}
Yes I have saved the file
It is in c_code directory
Please screenshot your entire VSC window
Also you're using some ancient GCC version (6.3, while the latest is 14)
Yes my gcc version is 6.30 I tried upgrading it
C:\MinGW\libexec\mingw-get\guimain.exe
When the GUI is open, tap Installation -> Update Catalogue. This will update the package list.
After that, tap Installation -> Mark All Upgrades. This will select all of the packages which can be upgraded.
Finally, tap Installation -> Apply Changes(this option is disabled) to apply the upgrades but not able to upgrade it
It says everything has been updated but the changes are not reflected in the terminal the gcc version are still 6.3.
There's no single "the" MinGW
There are better or worse versions of it
Here's a better one, for example
I have saved the file and using gcc version 14.1.0
Thank you it somewhat working
But I have 2 doubts here
Can you clarify me
Sometime I am getting the above error
@tired magnet Has your question been resolved? If so, type !solved :)
Undefined reference to WinMain usually happens when you’re on windows and you don’t have the main function declared
I see a lot of beginners who don’t know to save the file and that’s why they end up getting it
Thanks for the clarification
And why it is insisting to add stdio.h and int main instead of normal main()
- stdio.h is the header file that declares that the printf function
- The main function returns an int, so you need to specify that