Home > Backend Development > C++ > body text

Why am I getting an Undefined Reference to WinMain@16 when using wWinMain with Mingw?

Barbara Streisand
Release: 2024-11-05 10:59:02
Original
980 people have browsed it

Why am I getting an Undefined Reference to WinMain@16 when using wWinMain with Mingw?

wWinMain, Unicode, and Mingw

In this discussion, a developer encounters an error using the wWinMain function with Mingw as their compiler. This guide will explore the issue and provide solutions to resolve the error and address the question of using Unicode.

Problem

The developer experiences an undefined reference to WinMain@16 when compiling the program using Mingw. Replacing wWinMain with Winmain and PWSTR with LPSTR resolves the issue, but the developer wants to know if there is a better solution and the significance of not using Unicode.

Solution

For older versions of Mingw, a wrapper called mingw-unicode-main can be used. It provides support for wmain and wWinMain when compiling Unicode programs. The instructions for using this wrapper can be found in the project's GitHub repository: https://github.com/coderforlife/mingw-unicode-main.

For newer versions of Mingw, the -municode option should be used, as indicated in the mingw-unicode-main readme. This option enables support for Unicode in Mingw-w64.

Unicode considerations

Using Unicode is not always a significant concern. For simple programs that only require ASCII character support, using regular (CHAR) or TCHAR is sufficient. However, if the program will handle non-ASCII characters or internationalization, using Unicode is recommended.

Resources

  • [mingw-unicode-main](https://github.com/coderforlife/mingw-unicode-main/)
  • [Installing MinGW-w64](https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/rubenvb/gcc-4.7-release/)

The above is the detailed content of Why am I getting an Undefined Reference to WinMain@16 when using wWinMain with Mingw?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!