0

Error "undefined reference to 'WinMain'" id returned 1 exit status

In the constant variable printing part of c++ tutorial here, i copied everything in the example as it is checked numerous times but it keeps giving me UNDEFINED REFERENCE TO "WINMAIN" error. I created the header files properly and used it before for previous lessons but in this case when i try to use the header file like the example says, compiler gives me the above mentioned error. I am using Dev C++ ide. It may be some kind of coding issue or compiler issue. So if anyone find any answer, please reply.. thanks in advance

20th Oct 2020, 10:43 AM
Soumojit Chowdhury
Soumojit Chowdhury - avatar
7 Respostas
+ 2
Winmain as I recall is used for Windows GUI application, examples here are console based codes only. Did you *probably* created a GUI application project by accident?
20th Oct 2020, 10:50 AM
Ipang
+ 2
The error means that the compiler try to find WinMain() but it didn't. Either you didn't declare int main() Or your project type is something other than Console. (Normally Win32GUI)
20th Oct 2020, 10:52 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 1
Did you declare int main()?
20th Oct 2020, 10:45 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 1
Oh so i habe to declare console project type.. as i recall while creating the project for the header file i declared it as an empty project. So it will be ok if i do the examples on console project right?
20th Oct 2020, 10:55 AM
Soumojit Chowdhury
Soumojit Chowdhury - avatar
+ 1
it’s irrelevant here, but just so you know it’s “ld” that returned with exit code 1, not “id”. ld is the gnu linker. and as you mentioned you created a gui project instead of a console one.
20th Oct 2020, 11:14 AM
Flash
0
Yeah.. is there a problem? the example also declared int main()
20th Oct 2020, 10:46 AM
Soumojit Chowdhury
Soumojit Chowdhury - avatar