Reputation: 9
I have written a basic program in C language in the editor of Visual Studio Code but I am getting the following error while trying to compile it.
#include<stdio.h>
int main()
{
printf("Hello World");
return 0;
}
I am getting the following error message:
[Running] cd "c:\Users\Chaitanya\Documents\initial\" && gcc pro1.c -o pro1 && "c:\Users\Chaitanya\Documents\initial\"pro1 c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../libmingw32.a(main.o):(.text.startup+0xb0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status [Done] exited with code=1 in 0.198 seconds
Upvotes: 0
Views: 191
Reputation: 12673
There is a difference between console application and Win32 application. You chose the latter but programmed the former.
A console application has a main function called main
.
A Win32 application has a main function called WinMain
; the linker misses it so it bails out.
Actually a Win32 application has a main function called main
, too. But it is provided by the library it is linked with, and it calls WinMain
after preparing some Win32 stuff.
Upvotes: 1