October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Redmond desk4 min

How to Install GCC in MSYS2’s UCRT64 Environment on Windows

Use MSYS2's UCRT64 environment for a new GCC-based native Windows C setup. Install the compiler, test a program, and keep build tools and libraries compatible.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a new GCC setup that builds native Windows programs, install MSYS2 and use its UCRT64 environment. Open the UCRT64 terminal, install GCC with Pacman, then compile and run a small C program to verify the toolchain. MSYS2 also provides a Unix-like shell and other environments; keep the compiler and libraries you use within one compatible environment.

What MSYS2 provides—and which environment to choose

MSYS2 combines a package manager and Unix-like command-line tools with separate environments for different compiler toolchains and runtime targets. The MSYS environment supplies tools intended to run in MSYS’s compatibility environment. UCRT64 is the straightforward choice for GCC-based, 64-bit native Windows programs when a project does not require something else. CLANG64 is an LLVM/Clang alternative.

As an Amazon Associate I earn from qualifying purchases.

The MSYS2 project documentation advises, “If you are unsure, go with UCRT64.” Its environments page also records that MINGW64 is being deprecated; it is not the recommended starting point for a new setup. See MSYS2’s environment guide for the distinctions and current status.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check Windows compatibility and install MSYS2

The MSYS2 GUI installer requires 64-bit Windows 10 version 1809 or newer. Minimum Windows requirements for packages can differ by package family, so check the project’s live supported Windows versions and hardware page if you are unsure whether a particular package will run on your system.

  1. Download and run the installer from the official MSYS2 site.
  2. Follow the installer prompts and allow it to launch a terminal when installation finishes. The current installer opens a UCRT64 terminal.
  3. Use that UCRT64 terminal for the commands in the next section. If you open a different MSYS2 environment, package names and the resulting runtime target may differ.

Install and verify GCC in UCRT64

In the UCRT64 terminal, install the GCC package using Pacman, MSYS2’s package manager. The package name identifies the UCRT64 target:

pacman -S mingw-w64-ucrt-x86_64-gcc

When prompted, confirm the installation. Then check that the compiler is available:

gcc --version

To test a complete compile-and-run cycle, create hello.c in a working directory with this content:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#include <stdio.h>

int main(void) {
    puts("Hello, C");
    return 0;
}

From the same UCRT64 terminal and directory, compile and run it:

gcc hello.c -o hello.exe
./hello.exe

A version string from the first command and Hello, C from the second confirm that GCC can compile and run a basic program in this environment. For more on Pacman and package naming, see MSYS2’s package-management guide.

Add build tools only for your project’s build system

GCC is the compiler; a project may also need a build system and its supporting tools. There is no single extra package list that applies to every C project. Add the tools the project actually uses, and install matching packages from the same environment as GCC.

For CMake projects targeting Windows

Use MSYS2’s MinGW CMake package rather than a CMake package intended for MSYS-runtime builds. In UCRT64, the package pattern is mingw-w64-ucrt-x86_64-cmake. Confirm its current name in the package database before installing; the MSYS2 CMake guide identifies the MinGW CMake package family and recommends Ninja as the current default generator.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select the generator explicitly. With Ninja installed in the same environment, configure a build from the directory where you want the build files, substituting the actual source path:

cmake -G Ninja <path-to-source> -DCMAKE_BUILD_TYPE=Release

Then build with:

cmake --build .

cmake --build works across generators, so it is a useful build command even if the project uses another supported generator. MSYS2 also documents MSYS Makefiles and MinGW Makefiles; choose a generator that matches the intended target and installed tools. Consult Using CMake in MSYS2 for current package and generator guidance.

For Make or Autotools projects

Install Make and any other required build utilities from the same environment as the compiler. Which utilities are needed depends on the project’s instructions; do not install a blanket set without checking the build system’s requirements.

Keep runtimes and libraries compatible

MSYS2 environments can target different C runtimes and C++ standard libraries. Object files and static libraries built for different targets should not be mixed: runtime structures and types can differ, even when the files have familiar names such as .o or .a. For a beginner UCRT64 setup, keep GCC, dependencies, and build tools in UCRT64 and use libraries built for that target. The MSYS2 environment documentation explains the runtime distinctions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle paths at shell and Windows-tool boundaries

Within the MSYS2 shell, Unix-style paths such as /c/Users/Ada/project are natural for MSYS2 utilities. Native Windows programs may expect Windows-style paths instead. Be deliberate when passing a path from one kind of program to another; do not assume every tool interprets paths identically or casually mix shell paths with backslash paths.

MSYS2 provides cygpath to convert between Unix, Windows, and mixed path forms. Use it when a command or script passes paths across that boundary, and consult the filesystem paths guide for details.

Use the terminal from an editor if you prefer

You can edit code in an IDE or text editor while using the same MSYS2 environment for builds. Configure its integrated terminal or build commands to invoke the UCRT64 tools, rather than silently using a different compiler or runtime. MSYS2 maintains examples and notes for editor integration on its IDEs and text editors page.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.