0

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
1
  • 2
    Did you choose "console application" as the project type? Commented Aug 28, 2019 at 10:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.