Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined reference to `WinMain@16' while compiling [duplicate]

I just installed Visual Studio Code and was trying to run my code when this came up:

Undefined reference to `WinMain@16' while compiling

I searched through the web for a relevant answer, but none that I found worked.

Here is a more detailed output in the console:

cd "f:\" && g++ testing.cpp -o testing && "f:\"testing
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status,

By the way, I am using code-runner to run that single file. I have MinGW path all set up—though I don't know if that even matters.

here is what it looks like

like image 778
Jitesh Yadav Avatar asked Sep 11 '25 13:09

Jitesh Yadav


1 Answers

The code runner does not save your code before running it. You can see the commands it executes in the error snippet you have added

cd "f:\" && g++ testing.cpp -o testing && "f:\"testing

So make sure you save your code before running it. This happened with me and I wasted quite some time.

like image 100
Raghav Avatar answered Sep 13 '25 04:09

Raghav