Compile the Fortran program in Windows using gfortran

To compile Fortran code for Windows you need a Fortran compiler for Windows. Microsoft neither provides a built-in one nor offers one for sale. Third-party compilers are available, including gfortran, but you’ll need to install one yourself. If you want to use gfortran in particular, or if you like it simply because you don’t have to spend money to get it, then I would recommend obtaining it as part of mingw-w64. Alternatives are available from multiple vendors, some free of charge, but most for sale.

Note also that Windows expects executables to be named with an .exe extenstion, so you would want to use a variation on gfortran your compilation command:

gfortran -o program.exe  program.f

Leave a Comment