Home  >  Article  >  Backend Development  >  Why Am I Getting "Undefined Reference to `WinMain'" When Using wWinMain with MinGW?

Why Am I Getting "Undefined Reference to `WinMain'" When Using wWinMain with MinGW?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-05 22:39:02639browse

Why Am I Getting

Undefined Reference to WinMain When Using wWinMain (C MinGW)

When attempting to use wWinMain as the entry point for a Windows application using C and MinGW, you may encounter the error "undefined reference to `WinMain'". This issue arises due to the fact that MinGW does not support wWinMain in its CRT startup library.

To resolve this issue, you can use WinMain as the entry point instead. In your example code, modify wWinMain to WinMain and PWSTR pCmdLine to PSTR pCmdLine. This should resolve the error, as the program does not utilize the pCmdLine value.

If you later require unicode command line support, utilize LPWSTR cmd_line = GetCommandLineW(); instead of the WinMain argument.

The above is the detailed content of Why Am I Getting "Undefined Reference to `WinMain'" When Using wWinMain with MinGW?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn