undefined reference to WinMain_16

⌚Time: 2026-02-21 20:05:00

👨‍💻Author: Jack Ge

When I use MinGW GCC to compile Win32 programs, I get errors when compiling programs with the Unicode character set.

wWinMain and WinMain

wWinMain - Unicode version, command line arguments are wide characters

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow)

WinMain - ANSI version, command line arguments are multi-byte characters

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Winmain and wWinMain are basically the same. Unicode programs use the wWinMain function, but you can also use the WinMain function as the entry point.

I changed the function entry name to WinMain and changed the type of the lpCmdLine parameter from PWSTR to LPSTR, and it compiled successfully.