wWinmain, Unicode, and Mingw

For old versions of MinGW, you can use a wrapper:

mingw-unicode-main:

https://github.com/coderforlife/mingw-unicode-main/

Simple wrappers to add wmain and wWinMain support in MinGW

These wrappers allow for use of wmain / wWinMain in MinGW seamlessly
with Unicode (WCHAR), regular (CHAR), or the ability to choose
(TCHAR).

The instructions for using them are in the files. Also take a look at
other programs that use them.


For new versions of MinGW, you should use the -municode option, like it says in the mingw-unicode-main readme:

Note: This should no longer be used as MinGW now has a built-in
solution. Add -municode to the command line (and possibly extern “C”
to the wmain function).

The -municode option works with MinGW-w64. In 2012-07, when I tried MinGW, it did not have the -municode option.

Here is how to install MinGW-w64:

Target Win32:

  • Home > Toolchains targetting Win32 > Personal Builds > rubenvb > gcc-4.7-release:

    http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/

  • On Windows, you want “i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z”.

  • Extract folder to the root of your drive.

  • Rename the “mingw32” folder to “MinGW-32”.

Target Win64:

  • Home > Toolchains targetting Win64 > Personal Builds > rubenvb > gcc-4.7-release:

    http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.7-release/

  • On Windows, you want “x86_64-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z”.

  • Extract folder to the root of your drive.

  • Rename the “mingw64” folder to “MinGW-64”.


Unicode-related questions:

  • How do I use the wmain() entry point in Code::Blocks?
  • Compiling Windows program in Dev-C++ gives error
  • #define _UNICODE not working with MinGW + CodeBlocks

Leave a Comment

tech