Error compiling a .cpp file using MinGW

2

Today I reinstalled MinGW and setup it again, tested it several times with some programs in c ++ and was working fine, but now I try to create new programs and when I will compile using the command:

g++ -o file file.cpp

It accuses the following error:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to 'WinMain@16'

I was able to solve the problem by changing the main statement from:

int main()

To:

int main(int argc, char* argv[])

And now I can compile programs normally. However, I would like to know what the source of the error was, since earlier today I wrote and compiled programs with the main structure of the example above without any problem. Could anyone tell me?

    
asked by anonymous 27.05.2018 / 23:41

0 answers