To use the GCC version installed, you need to launch not the base MSYS prompt, but the UCRT64 one. (Hopefully) MSYS2 has installed multiple shortcuts for you, if you look at the start menu you should see one that has UCRT64 in the name. When you launch it correctly your prompt will look like e.g. zulfi@DESKTOP-070V6RM UCRT64 ~ $ It's this shell because you installed mingw-w64-ucrt-x86_64-gcc, notice the "ucrt" in the name there. For some background - Why does this happen? MSYS2 docs don't explain this well, but there are "2 layers" of the MSYS2 system. There's the top level one (just called MSYS) that provides the unix tools and the shell, but these tools rely on a compatability layer to work on windows (provided by msys-2.0.dll). Below that, the environment lets you install compilers that generate code for a native toolchain (can run on windows without any compatability stuff), but this is complicated by multiple options due to legacy. UCRT64 is the recommended one for starting out which is why it's in the docs. But since there are other options, MSYS2 provides multiple shells so you can have compilers for multiple different toolchains installed at the same time without breaking each other. So the compiler you installed ucrt-x86_64-gcc means: ucrt = ucrt C runtime library; x86_64 = 64 bit windows; gcc = the GCC compiler (Clang is the other option). To put it simply, do your programming for now in the UCRT64 shell and it should work. But to installations/updates from the main MSYS shell. Answer from likely_to_be_wrong on reddit.com
🌐
Reddit
reddit.com › r/learnprogramming › can't seem to make msys2 gcc work at all
r/learnprogramming on Reddit: Can't seem to make MSYS2 GCC work at all
June 4, 2023 -

the instalation of GCC seemed to work fine, but when i run gcc -- version, i get greeted by "bash:gcc: command not found" response. i followed the instructions with every step. what could be the issue?

I found a fix thanks to chatgpt ( who would've thought). turns out the MSYS2 link from the vs code page was simply outdated, so i used this one from the MSYS2 page and ran the commands in the ucrt window. I will leave this here in hopes someone else finds and needs this

🌐
Reddit
reddit.com › r/askprogramming › can't install gcc in msys2 environment
r/AskProgramming on Reddit: Can't install gcc in MSYS2 environment
March 29, 2025 -

Hi,

I have installed gcc in Windows 11 environment, but I want to execute gtk, I searched the following link:

https://www.msys2.org/

I installed msys2-x86_64-2025221.exe

After that I tried the following command:

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

but finally gcc is not working please guide me.

The output is:

MSYS ~
$ pacman -S mingw-w64-ucrt-x86_64-gcc
resolving dependencies...
looking for conflicting packages...

Packages (16) mingw-w64-ucrt-x86_64-binutils-2.44-1
              mingw-w64-ucrt-x86_64-crt-git-12.0.0.r576.g49111ba98-1
              mingw-w64-ucrt-x86_64-gcc-libs-14.2.0-3  mingw-w64-ucrt-x86_64-gettext-runtime-0.24-1
              mingw-w64-ucrt-x86_64-gmp-6.3.0-2
              mingw-w64-ucrt-x86_64-headers-git-12.0.0.r576.g49111ba98-1
              mingw-w64-ucrt-x86_64-isl-0.27-1  mingw-w64-ucrt-x86_64-libiconv-1.18-1
              mingw-w64-ucrt-x86_64-libwinpthread-git-12.0.0.r576.g49111ba98-1
              mingw-w64-ucrt-x86_64-mpc-1.3.1-2  mingw-w64-ucrt-x86_64-mpfr-4.2.1-2
              mingw-w64-ucrt-x86_64-windows-default-manifest-6.4-4
              mingw-w64-ucrt-x86_64-winpthreads-git-12.0.0.r576.g49111ba98-1
              mingw-w64-ucrt-x86_64-zlib-1.3.1-1  mingw-w64-ucrt-x86_64-zstd-1.5.7-1
              mingw-w64-ucrt-x86_64-gcc-14.2.0-3

Total Download Size:    65.83 MiB
Total Installed Size:  519.08 MiB

:: Proceed with installation? [Y/n] Y
:: Retrieving packages...
 mingw-w64-ucrt-x86_64-gcc-...    43.5 MiB  14.3 MiB/s 00:03 [###############################] 100%
 mingw-w64-ucrt-x86_64-isl-...  1453.5 KiB   420 KiB/s 00:03 [###############################] 100%
 mingw-w64-ucrt-x86_64-libi...   725.4 KiB   930 KiB/s 00:01 [###############################] 100%
 mingw-w64-ucrt-x86_64-gcc-...  1021.6 KiB   823 KiB/s 00:01 [###############################] 100%
 mingw-w64-ucrt-x86_64-zstd...   642.3 KiB  2.55 MiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-gmp-...   578.5 KiB   963 KiB/s 00:01 [###############################] 100%
 mingw-w64-ucrt-x86_64-mpfr...   535.7 KiB  1739 KiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-mpc-...   128.3 KiB   594 KiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-gett...   311.6 KiB   499 KiB/s 00:01 [###############################] 100%
 mingw-w64-ucrt-x86_64-zlib...    92.1 KiB   165 KiB/s 00:01 [###############################] 100%
 mingw-w64-ucrt-x86_64-winp...    39.8 KiB   128 KiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-binu...     6.0 MiB   994 KiB/s 00:06 [###############################] 100%
 mingw-w64-ucrt-x86_64-head...     6.4 MiB  1046 KiB/s 00:06 [###############################] 100%
 mingw-w64-ucrt-x86_64-libw...    28.6 KiB  97.4 KiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-wind...     3.0 KiB  12.9 KiB/s 00:00 [###############################] 100%
 mingw-w64-ucrt-x86_64-crt-...     4.6 MiB   679 KiB/s 00:07 [###############################] 100%
 Total (16/16)                    65.8 MiB  9.35 MiB/s 00:07 [###############################] 100%
(16/16) checking keys in keyring                             [###############################] 100%
(16/16) checking package integrity                           [###############################] 100%
(16/16) loading package files                                [###############################] 100%
(16/16) checking for file conflicts                          [###############################] 100%
(16/16) checking available disk space                        [###############################] 100%
:: Processing package changes...
( 1/16) installing mingw-w64-ucrt-x86_64-libwinpthread-git   [###############################] 100%
( 2/16) installing mingw-w64-ucrt-x86_64-gcc-libs            [###############################] 100%
( 3/16) installing mingw-w64-ucrt-x86_64-libiconv            [###############################] 100%
( 4/16) installing mingw-w64-ucrt-x86_64-gettext-runtime     [###############################] 100%
( 5/16) installing mingw-w64-ucrt-x86_64-zlib                [###############################] 100%
( 6/16) installing mingw-w64-ucrt-x86_64-zstd                [###############################] 100%
( 7/16) installing mingw-w64-ucrt-x86_64-binutils            [###############################] 100%
( 8/16) installing mingw-w64-ucrt-x86_64-headers-git         [###############################] 100%
( 9/16) installing mingw-w64-ucrt-x86_64-crt-git             [###############################] 100%
(10/16) installing mingw-w64-ucrt-x86_64-gmp                 [###############################] 100%
(11/16) installing mingw-w64-ucrt-x86_64-isl                 [###############################] 100%
(12/16) installing mingw-w64-ucrt-x86_64-mpfr                [###############################] 100%
(13/16) installing mingw-w64-ucrt-x86_64-mpc                 [###############################] 100%
(14/16) installing mingw-w64-ucrt-x86_64-windows-default...  [###############################] 100%
(15/16) installing mingw-w64-ucrt-x86_64-winpthreads-git     [###############################] 100%
(16/16) installing mingw-w64-ucrt-x86_64-gcc                 [###############################] 100%

zulfi@DESKTOP-070V6RM MSYS ~
$ gcc --version
-bash: gcc: command not found

However, gcc is already working on my computer on windows shell,

c:\msys64>gcc
gcc: fatal error: no input files
compilation terminated.

I want to install gtk.

Somebody please guide me.

Zulfi.

Top answer
1 of 1
3
To use the GCC version installed, you need to launch not the base MSYS prompt, but the UCRT64 one. (Hopefully) MSYS2 has installed multiple shortcuts for you, if you look at the start menu you should see one that has UCRT64 in the name. When you launch it correctly your prompt will look like e.g. zulfi@DESKTOP-070V6RM UCRT64 ~ $ It's this shell because you installed mingw-w64-ucrt-x86_64-gcc, notice the "ucrt" in the name there. For some background - Why does this happen? MSYS2 docs don't explain this well, but there are "2 layers" of the MSYS2 system. There's the top level one (just called MSYS) that provides the unix tools and the shell, but these tools rely on a compatability layer to work on windows (provided by msys-2.0.dll). Below that, the environment lets you install compilers that generate code for a native toolchain (can run on windows without any compatability stuff), but this is complicated by multiple options due to legacy. UCRT64 is the recommended one for starting out which is why it's in the docs. But since there are other options, MSYS2 provides multiple shells so you can have compilers for multiple different toolchains installed at the same time without breaking each other. So the compiler you installed ucrt-x86_64-gcc means: ucrt = ucrt C runtime library; x86_64 = 64 bit windows; gcc = the GCC compiler (Clang is the other option). To put it simply, do your programming for now in the UCRT64 shell and it should work. But to installations/updates from the main MSYS shell.
🌐
Reddit
reddit.com › r/olkb › qmk error avr-gcc: command not found
r/olkb on Reddit: QMK Error avr-gcc: command not found
December 30, 2021 -

I tried to compile a default key map and get the error message "sh: avr-gcc: comand not found".

When using make iris/rev2:default following error message appeared.

$ make iris/rev2:default
QMK Firmware 0.6.246
Making iris/rev2 with keymap default

/bin/sh: avr-gcc: command not found
sh: avr-gcc: command not found
sh: avr-gcc: command not found
make[1]: *** [tmk_core/rules.mk:256: gccversion] Error 127
Make finished with errors
make: *** [Makefile:544: iris/rev2:default] Error 1

I use windows10 and Msys2 64bit with "MSYS2 MinGW 64-bit".

I tried following to solve this error, but didn't solve the problem.

reinstall msys2 and qmk

rerun util/qmk_install.sh

run echo 'export PATH="/usr/local/opt/avr-gcc@7/bin:$PATH"' >> ~/.bash_profile and restart terminal

run pacman -S avr-gcc and "Error target not found: avr-gcc" appeared.

This is my first time of building key map, then I'm a beginner.

Any information would greatly help.

🌐
Reddit
reddit.com › r/cpp_questions › need help with msys2 mingw installation
r/cpp_questions on Reddit: need help with msys2 mingw installation
November 8, 2022 -

so i tried to follow the basic guide as stated on the msys2 site and installed the program and ran the pacman commands....i included the mingw bin folder in the environment variables but when i ran the gcc -- version command in the command prompt...it didnt recognize it. the bin folder in my mingw64 directory is empty btw i checked a youtube video for the same and the bin folder had some files

Find elsewhere
🌐
GitHub
github.com › msys2 › MSYS2-packages › issues › 4543
Acquiring gcc / g++ to run C/C++ files · Issue #4543 · msys2/MSYS2-packages
April 18, 2024 - Though it told me that it could not find the command g++ now I tried to fix that issue, following a bit along by researching on google. I found and followed the top answer of this stackoverflow issue as well as mostly things from issue #1190 I think that I could now get around the issue of it not being satisfied. Now I get stumped on step 10 / 11 from the stackoverflow question. Because each time I try to run gcc --version I'll just get the respond -bash: gcc: command not found
Author   msys2
🌐
GitHub
github.com › msys2 › setup-msys2 › issues › 118
"command not found" when trying to call CMake or GCC after installing them · Issue #118 · msys2/setup-msys2
March 16, 2021 - Hi. Consider following all steps available at the official MSYS2 web site. After finishing them, install the CMake and GCC (I have been trying the i686 option): $ pacman -S mingw-w64-i686-cmake mingw-w64-i686-gcc Now, try to use CMake: $...
Author   msys2
🌐
Reddit
reddit.com › r/learnprogramming › msys2 command not working
r/learnprogramming on Reddit: MSYS2 command not working
February 25, 2023 -

so i wanted to install the gtk package with this command > pacman -s mingw-w64-x86_64-gtk3

but it just says -bash: -S: command not found

note: if i search for mysys in start i get like 5 options so i just click on the first one

🌐
Reddit
reddit.com › r/c_programming › msys2 / mingw gcc argv command line file globbing on windows
r/C_Programming on Reddit: MSYS2 / MINGW gcc argv command line file globbing on windows
October 29, 2024 -

The gcc compiler for MSYS2 on windows does some really funky linux shell emulation.

https://packages.msys2.org/packages/mingw-w64-x86_64-crt-git

It causes the following:

> cat foo.c
#include <stdio.h>
int main( int argc, char**argv ) {
  printf("%s\n", argv[1]);
}
> gcc foo.c
> a.exe "*"
.bashrc (or some such file)

So even quoting the "*" or escaping it with \* does not pass the raw asterisk to the program. It must do some funky "prior to calling main" hooks in there because it's not the shell, it's things specifically built with this particular compiler.

> echo "*"
*

However, there's an out.

https://github.com/search?q=repo%3Amsys2-contrib%2Fmingw-w64%20CRT_glob&type=code

This is the fix.

> cat foo.c
#include <stdio.h>
int _CRT_glob = 0;
int main( int argc, char**argv ) {
  printf("%s\n", argv[1]);
}
> gcc foo.c
> a.exe "*"
*

FYI / PSA

This is an informational post in reply to a recent other post that the OP deleted afterwards, thus it won't show up in searches, but I only found the answer in one stackoverflow question and not at all properly explained in MINGW/MSYS documentation (that I can find, feel free to comment with an article I missed), so I figure it's better to have some more google oracle search points for the next poor victim of this to find. :-p

🌐
Reddit
reddit.com › r/c_programming › how to install 64-bit msys2, really?
r/C_Programming on Reddit: How to install 64-bit MSYS2, really?
July 10, 2025 -

See title -- it's what I'm trying to do. I'd like the MSYS2 installaton to work with Eclipse CDT, which is why I'm also taking these instructions into account. Working with CDT is not my primary goal though -- most important is to set up a 64-bit MSYS2/MinGW dev environment.

I've downloaded and installed msys2-x86_64-20250622.exe. I'm pretty sure that's the correct installer for a 64-bit Windows 10 machine, which is what I'm on. So far so good.

So I run it, and start up "MSYS2" from the Start menu, run "pacman -Syu", then "pacman -S gcc make vim".

But then I look at the instructions linked above, and it seems that "pacman -S gcc" is a mistake, even though gcc works fine from the MSYS2 command line after installation. Apparently, in order for things to work with Eclipse CDT, I should have done "pacman -S mingw-w64-ucrt-x86_64-gcc", which installs GCC stuff into /msys64/ucrt64. Strangely though, the urct64 subdir is is not on MSYS' own PATH, so after installation the binaries aren't found when called from the MSYS2 console.

So here's one question: why does MSYS2 have a "normal" GCC package (with all its dependencies), and also an alternative "UCRT64" GCC package, with its own dependencies (also marked URCT64). The suffix "64" seems to suggest that that's what I want on a 64-bit machine -- but since the MSYS2 core that I installed is itself 64-bit, I have no idea why I would have to specify the 64-bit packages explicitly -- and even less of an idea as to why the binaries inside those "ucrt64" packages aren't even put on MSYS2' own PATH.

BUT! Now things turn even more complicated when I read this MinGW page. As it turns out, the MSYS2 distributation has created multiple additional startup-links in the Windows start folder, including an "MSYS2 UCRT64", "MSYS2 CLANG64", "MSYS2 MINGW64", etc. Great! What the heck are these for? And why does each of these variants require its own variation of the GCC package and its dependencies?

And why isn't any of this explained anywhere? (Or maybe it is. But DuckDuckGo doesn't know about it.)

First of all, I'd really like to know how I produce 64-bit executables for Windows, using MSYS2. If I run the "regular" (non-UCRT64 gcc", will it create a 32-bit executable or a 64-bit?

Help please.

PS. Among the dependencies of the regular gcc package are msys2-w32api-headers and msys2-w32api-runtime. Is "win32api" an indication that using this gcc I'll be compiling for 32-bit Windows? Or is "win32api" simply the legacy name left over from the 1990's, designating the Windows API against which all Windows programs (regardless whether 32-bit or 64-bit) are compiled?

Top answer
1 of 2
2
They are called Environments , basically determining what standard C library to use (cygwin, ucrt, msvcrt), what compiler to use (gcc, clang) and architecture (i686 (32-bit), x86_64 (64-bit), aarch64 (64-bit arm)). They have different launchers that just sets up the correct environment variables. Note that the "cygwin" environment means it requires the cygwin DLLs to work (which isn't shipped with windows) (msys2 is based on cygwin) but you get access to unix/linux-like functions like fork() (although even that function is still problematic ). If you want to build 64-bit executables that work outside of MSYS2, use UCRT64. If you want to build executables for yourself that need some of the unix/linux API and are OK that it needs MSYS2, use MSYS. (There isn't a official 32-bit of MSYS2 anymore, so it's always 64-bit). Is "win32api" an indication that using this gcc I'll be compiling for 32-bit Windows? Or is "win32api" simply the legacy name left over from the 1990's, designating the Windows API against which all Windows programs (regardless whether 32-bit or 64-bit) are compiled? Microsoft calls it Win32 API despite working both for 32-bit and 64-bit.
2 of 2
1
> If I run the "regular" (non-UCRT64 gcc", will it create a 32-bit executable or a 64-bit? Try it. As I can recall, it has produced 64 app for me. Use -m64 option if not. The compiler executable should be the same for any targets, I hope. My distributive, downloaded from https://www.msys2.org/ , has been named msys2-x86_64-20230526.exe
🌐
Reddit
reddit.com › r/mechanicalkeyboards › qmk help: avr-gcc command: not found
r/MechanicalKeyboards on Reddit: QMK Help: avr-gcc command: not found
October 15, 2019 -

I recently downloaded the QMK stuff to add macros to my TADA68, but whenever I try to make the default layout I get this output:

QMK Firmware 0.7.38

WARNING:

Some git sub-modules are out of date or modified, please consider running:

make git-submodule

You can ignore this warning if you are not compiling any ChibiOS keyboards,

or if you have modified the ChibiOS libraries yourself.

Making tada68 with keymap default

/bin/sh: avr-gcc: command not found

tmk_core/protocol/lufa.mk:14: lib/lufa/LUFA/makefile: No such file or directory

make[1]: *** No rule to make target 'lib/lufa/LUFA/makefile'. Stop.

Make finished with errors

make: *** [Makefile:574: tada68:default] Error 1

I've looked at several other Reddit threads in an effort to fix this issue. I've reinstalled QMK a few times now at least, reinstalled MSYS2, etc etc. I've tried everything I can think of. Does anyone know how I can fix this?

EDIT: Doing this on W10, thru MSYS2 MINGW64

EDIT 2: Ok I got it to work. I deleted/uninstalled EVERYTHING, and then started over again. I missed the instillation instructions on the MSYS2 website; there are two commands there that need to be run. Not sure if that was what was causing the issue before, but future people who are having problems: make sure to run every command and follow all directions!

🌐
Reddit
reddit.com › r/olkb › qmk make error avr-gcc
r/olkb on Reddit: QMK Make Error avr-gcc
August 9, 2018 -

I'm trying to build my layout for the first time, but I keep running into this error that says that avr-gcc is missing.

I'm on windows and I'm using msys2. I ran utils/msys2_install.sh to install everything initially. I also tried running utils/qmk_install.sh but it didn't do anything. Thanks!

$ make levinson/rev2:default
QMK Firmware 0.6.87
Making levinson/rev2 with keymap default

/bin/sh: avr-gcc: command not found
sh: avr-gcc: command not found
sh: avr-gcc: command not found
make[1]: *** [tmk_core/rules.mk:243: gccversion] Error 127
Make finished with errors
make: *** [Makefile:544: levinson/rev2:default] Error 1
🌐
GitHub
github.com › msys2 › MSYS2-packages › issues › 293
install gcc on msys2 · Issue #293 · msys2/MSYS2-packages
July 14, 2015 - Hi, whats the right package to install gcc on msys2? pacman -S gcc pacman -S mingw-w64-x86_64-gcc I use: msys2-x86_64-20150512.exe Thanks, A
Author   msys2
🌐
Cplusplus
cplusplus.com › forum › windows › 227005
Let msys2 configure find mingw gcc/g++ - C++ Forum
December 17, 2017 - I have gcc.exe, g++.exe, make.exe, etc. in C:\MinGW\bin In the msys2 terminal, I can say PATH=$PATH:/c/MinGW/bin but it does not save this change after I close the msys terminal. A StackOverflow question says I have to edit ~/.profile.
🌐
Reddit
reddit.com › r › olkb › comments › 96jxrz › vitamins_included_make_error_avrgcc_command_not
r/olkb - Vitamins Included make error: avr-gcc command not found
August 14, 2018 - $ ls ~/qmk_utils activate_msys2.sh drivers.txt qmk_driver_installer.exe avr8-gnu-toolchain flip teensy_loader_cli.exe dfu-programmer FlipInstaller.exe dfu-util-0.9-win64 gcc-arm-none-eabi