Set the environment variable path as C:\msys64\ucrt64\bin in case if you have installed gcc using pacman -S mingw-w64-ucrt-x86_64-gcc.

OR

You can install gcc using: pacman -S mingw-w64-x86_64-gcc and set environment variable path as C:\msys64\mingw64\bin.

Answer from Shiv Buyya on Stack Overflow
🌐
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

🌐
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   silvioprog
🌐
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   Arnold1
🌐
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.
🌐
MSYS2
msys2.org
MSYS2
It consists of a command line terminal called mintty, bash, version control systems like git and subversion, tools like tar and awk and even build systems like autotools, all based on a modified version of Cygwin. Despite some of these central parts being based on Cygwin, the main focus of MSYS2 is to provide a build environment for native Windows software and the Cygwin-using parts are kept at a minimum. MSYS2 provides up-to-date native builds for GCC, mingw-w64, CPython, CMake, Meson, OpenSSL, FFmpeg, Rust, Ruby, just to name a few.
🌐
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   ZeitHeld
Find elsewhere
🌐
Lean
lean-lang.org › lean4 › doc › make › msys2.html
lean4/doc/make/msys2.md at master · leanprover/lean4
However, if you plan to use this build to compile lean programs to executable binaries using lake build in normal Windows command prompt outside of msys2 environment you will also need to add a windows version clang to your path. -bash: gcc: command not found ·
Author   leanprover
🌐
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.
🌐
Stack Overflow
stackoverflow.com › questions › 25195311 › how-can-i-get-msys-to-recognize-gcc
How can I get msys to recognize gcc? - Stack Overflow
1 MSYS2, change the gcc toolchain PATH to "C:\TDM-GCC-32" instead of using the default MinGW-w64 one?
🌐
Narkive
msys2-users.narkive.com › bmw8LbRk › scons-and-mingw-w64-x86-64-gcc
[Msys2-users] scons and mingw-w64-x86_64-gcc
Although the g++ sh: o: command not found If I install the gcc package scons works, but I want to be able to use the other mingw-w64 packages like boost, etc. Is there anyway to fix this? How are others using scons and mingw-w64? to use mingw-w64-x86_64-gcc you need run MSYS2 with mingw64_shell.bat or modify PATH variable export PATH=/mingw64/bin:$PATH I did run mingw64_shell.bat and g++ is in the path: Running it in bash works fine.
🌐
GitHub
github.com › scipy › scipy › issues › 9487
build problem (can't install MSYS) · Issue #9487 · scipy/scipy
November 15, 2018 - gfortran gcc · (as suggested) the MSYS2 terminal spits: bash: gfortran: command not found bash: gcc: command not found · in the instructions at the webpage: "These commands should give errors as we have not provided any arguments to them. However an error also implies that they are accessible on the path." but, if they are not accessible on the path, there is no suggested action to take!, so I am in a stalemate.
🌐
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.

🌐
GitHub
github.com › msys2 › MINGW-packages › issues › 6560
php-config and g++ not found · Issue #6560 · msys2/MINGW-packages
June 6, 2020 - $ make mkdir -p shared/common mkdir -p shared/zend g++ -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -MD -g `php-config --includes` -fpic -o shared/common/modifiers.o common/modifiers.cpp /bin/sh: php-config: command not found /bin/sh: g++: command not found make: *** [Makefile:213: shared/common/modifiers.o] Error 127
Author   TadavomnisT