1

I'm a totally beginner.

I wanted to compile C by MinGW in Visual Studio Code, but I got an error code at the terminal in Visual Studio Code. At first, I created a file just under Windows (C:).

Source code

#include <stdio.h>

int main(void) {
    printf("Hello World!");
    return 0;
}

Terminal

PS C:\vscode> gcc hello.c
ingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../libmingw32.a(main.o):(c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mn@16'
ingw32/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
the busybee
  • 10,755
  • 3
  • 13
  • 30
Jack
  • 125
  • 1
  • 1
  • 10

2 Answers2

1

With no code... my best guess would be you don't have int main() at the beginning of your program OR main() is named something other than main.

static_cast
  • 1,174
  • 1
  • 15
  • 21
1

Never tried gcc for Windows, but I would compile only with:

gcc hello.c

or may be with:

gcc hello.c -o program.exe
Nick
  • 9,962
  • 4
  • 42
  • 80