0

Code:

#include <bits/stdc++.h>
using namespace std;

int main() {
    cout << "hi" << endl;

    return 0;
}

When I compile it, it returns:

C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain' 
collect2.exe: error: ld returned 1 exit status

How do I fix this issue, by the way, I am using Vim?

Psycho
  • 3
  • 1
  • 2
  • What is the command line you are using to compile? – Retired Ninja Sep 29 '20 at 04:24
  • 1
    `WinMain` is a function that is required when compiling a Windows application. It looks like you are trying to write a Console application, which in most compilers is usually the default option. It looks like your compiler is configured to build a Windows application. – paddy Sep 29 '20 at 04:30
  • #RetiredNinja Command line: :!g++ % – Psycho Sep 29 '20 at 04:43
  • [Why should I not #include ?](https://stackoverflow.com/Questions/31816095/Why-Should-I-Not-Include-Bits-Stdc-H.) and [Why is "using namespace std;" considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – Some programmer dude Sep 29 '20 at 05:09
  • Are you able to build it directly from the terminal? – HolyBlackCat Sep 29 '20 at 07:08

0 Answers0