Install gfortran on Windows 11

MSYS2 option

On Windows 11 the simplest path for beginners is MSYS2 with the UCRT64 environment.

MSYS2 provides a Unix style shell plus a package manager, so install and update steps stay short and repeatable.

Install with pacman

Open the MSYS2 UCRT64 terminal from the Start menu and update the base system first, then add the Fortran compiler package.

pacman -Syu

pacman -S mingw-w64-x86_64-gcc-fortran

Accept the default package selection when asked. The download takes a few minutes on a first install.

Verify with gfortran --version

Open a fresh UCRT64 terminal and ask the compiler for its version number.

gfortran --version

GNU Fortran 13.2.0

Any recent version is fine for this course. If the command is not found, move to the PATH notes below.

PATH notes

The compiler is visible only where the MSYS2 UCRT64 bin directory is on PATH. The Start menu shortcut sets this for you, so prefer it over the generic Windows terminal at first.

Close and reopen the terminal after install, then check the resolved location.

which gfortran

/ucrt64/bin/gfortran.exe

If an editor or a separate terminal can not find gfortran, start that tool from the UCRT64 shell or add the bin directory to user PATH and restart the tool.

The code on this page was not run: it needs Windows.

Article author: Arthur Isaev