UTF-8 oriented MinGW-w64 GCC toolchain.
The toolchain is a UCRT-based toolchain plus extensions for UTF-8 programming. That is to say, without special arguments, it works as a common UCRT-based toolchain.
The toolchain is static by default. To opt-in shared runtime libraries, copy $prefix/lib/shared-unstable/* to $prefix/.
-mcrtdll=utf8-ucrt and -stdlib=libutf8-stdc++ (compile time and link time) enable UTF-8 C and C++ standard library (U8CRT) mode. In this mode, the compiler and linker automatically link UTF-8 variant of ucrt and libstdc++.
This is good for beginners or simple programs. No changes are required to the source code if it only calls C and C++ standard library functions.
Boost.Nowide’s nowide::narrow and nowide::widen is recommended for Win32 API calls. The standalone version of Boost.Nowide is included in the toolchain.
NEVER MIX UTF-8 and non-UTF-8 C and C++ standard libraries. i.e. use BOTH flags or NEITHER for C++.
-mutf8 (link time) enables UTF-8 manifest mode. In this mode, the compiler automatically embeds UTF-8 manifest into the executable.
This is good for GUI programs that target Windows 10 1903 or later, and console programs that target Windows 10 22H2 or later (which defaults to Windows Terminal that supports UTF-8 input). No changes are required to the source code as long as the program does not call GDI functions.
The build scripts and patches are located at MinGW Lite repository. See build instructions there (64-u8crt, 32-u8crt).
MinGW ∞ adds additional arguments --abi-name=∞{64,32}-{next,current}, --pkg-prefix=infinity{64,32}.
- Default CRT: ucrt.
- Exception model: seh (64-bit), dwarf (32-bit).
- Thread model: posix.
- Thread local storage: native (16.x), emulated (15.x).
- Minimum OS version: Windows Server 2003 SP2 (x64), Windows XP SP3 (x86).
- The tools are internally UTF-8 and use UTF-8 in pipes.
- Compiler warning of invalid UTF-8 sequence is enabled by default unless
-finput-charsetor-Wno-invalid-utf8is specified. - Compile and link flag
-mcrtdll=utf8-ucrt.- Compile time: define
_UCRT,UNICODE,_UNICODE.UNICODEand_UNICODEare defined to avoid passing narrow UTF-8 strings to ANSI WinAPI getting silently compiled.
- Link time: link UTF-8 variant of ucrt,
-lutf8-ucrt -lutf8-musl -lmingwex -lutf8-ucrt.libutf8-ucrtis ucrt import library with UTF-8 thunks that convert narrow strings to wide strings and call their wide versions.libutf8-muslimplements UTF-8 stdio by porting musl functions.
- Compile time: define
- Compile and link flag
-stdlib=libutf8-stdc++.- Compile time: set proper C++ standard library header search path.
- Link time: link UTF-8 variant of libstdc++,
-lutf8-stdc++.libutf8-stdc++static library is identical tolibstdc++.libutf8-stdc++shared library is almost same tolibstdc++, except that it links to UTF-8 variant of ucrt.
- Link flag
-mutf8.- Embed UTF-8 manifest.
- When building a console application (without
-mwindows), also enable UTF-8 code page.- On starting, set console code page to active code page (
SetConsoleCP(GetACP()); SetConsoleOutputCP(GetACP());). - On exiting, restore console code page.
- On starting, set console code page to active code page (