Install MSYS2 on Windows

MinGW has been bringing GNU compiler tools to Windows since the late 1990s. MSYS2 provides GNU tools including MinGW on Windows using pacman package manager.


Download msys2-x86_64-*.exe and run the installer, installing to C:/msys64. MSYS2 needs to be on a non-FAT / non-ExFAT drive capable of symbolic links, such as C:.

Start the MSYS2 console in the Windows Start menu, which sets up all the needed paths, just for that terminal session. Update MSYS2 to get the latest packages in the MSYS2 terminal. Run this command multiple times until it says “nothing to do”.

pacman -Syuu


To use MSYS2 / MinGW64 programs from PowerShell and Windws Command Prompt, add MinGW64 to Windows PATH, typically C:/msys64/mingw64/bin. This usually works without issues.

Otherwise, to keep GCC and other MSYS2 programs isolated to its own console, use “MSYS2 MinGW 64-bit” console from the Windows Start menu.


From MSYS2 command prompt, tasks include:

Search for packages:

pacman -Ss gcc

Install MinGW packages

  • gcc: pacman -S mingw64/mingw-w64-x86_64-gcc
  • gfortran: pacman -S mingw64/mingw-w64-x86_64-gcc-fortran
  • HDF5: pacman -S mingw64/mingw-w64-x86_64-hdf5
  • ninja: pacman -S mingw64/mingw-w64-x86_64-ninja
  • make: pacman -S mingw64/mingw-w64-x86_64-make
  • pkg-config: pacman -S mingw64/mingw-w64-x86_64-pkg-config
  • aspell: pacman -S mingw64/mingw-w64-x86_64-aspell mingw64/mingw-w64-x86_64-aspell-en

If you have confusion about why another version of a program is being used, check executable location like:

where gcc

You may need to reorder directories in your Windows Path variable, for example GNU Octave may need to be moved lower in the Path list.

When packages are installed in MinGW64, you must run from from MSYS2 MinGW64 terminal, or have added MSYS2 MinGW64 to your Command Prompt Path.