How to compile GRASS GIS on MS Windows

This page explains how to compile portable GRASS GIS on MS Windows using these scripts.

There is a great wiki page that explains a step-by-step procedure on how to compile GRASS GIS on MS Windows, but it requires the installation of Visual Studio (optionally?) and installs compiled GRASS GIS into the OSGeo4W directory structure. Since I just wanted to compile and run it from the Git repository, I needed to slightly modify the steps in the wiki page.

See also How to cross-compile GRASS GIS for MS Windows.

1   Installing OSGeo4W

  1. Download and run the OSGeo4W installer (64-bit or 32-bit)
  2. Advanced Install, Next
  3. Install from Internet, Next
  4. C:\OSGeo4W64 (64-bit) or C:\OSGeo4W (32-bit), Next
  5. Next
  6. Direct Connection, Next
  7. Select a download site, Next
  8. Install the following packages:
    • cairo
    • fftw
    • fftw-devel (32-bit only)
    • freetype-devel
    • freetype-devel-mingw (32-bit only)
    • gdal-ecw
    • gdal-mrsid
    • liblas-devel
    • libxdr
    • msys
    • pdcurses
    • python3-pywin32
    • python3-wx
    • regex-devel
    • wxpython
    • zstd-devel
  9. The following packages are required by GRASS GIS, but they will be automatically installed by dependency.
    • gdal
    • geos
    • iconv
    • libjpeg
    • libpng
    • libpq
    • libtiff
    • proj
    • sqlite3
    • zlib
    • zstd


  1. Download the OSGeo4W installer (64-bit or 32-bit)
  2. Start the cmd window
  3. Run the following command in the cmd window:
    • For 64-bit systems,
      osgeo4w-setup-x86_64.exe -A -g -k -q -s -P cairo,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,msys,pdcurses,python3-numpy,python3-pywin32,python3-wx,regex-devel,wxpython,zstd-devel
    • For 32-bit systems,
      osgeo4w-setup-x86.exe -A -g -k -q -s -P cairo,fftw,fftw-devel,freetype-devel,freetype-devel-mingw,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,msys,pdcurses,python3-pywin32,python3-wx,regex-devel,wxpython,zstd-devel

2   Installing MSYS2

  1. Download and run the MSYS2 installer (as of February 4, 2021, 64-bit or 32-bit)
  2. Next
  3. C:\msys64 (64-bit) or C:\msys32 (32-bit), Next
  4. Next
  5. Uncheck Run MSYS2 64bit now (64-bit) or Run MSYS2 32bit now (32-bit), Finish
  6. Run MSYS2 MinGW 64-bit (64-bit) or MSYS2 MinGW 32-bit (32-bit)
  7. Install the following packages (both 64-bit and 32-bit)
    pacman --noconfirm -S tar libintl make flex bison diffutils git dos2unix zip
  8. Install these packages:
    • mingw-w64-x86_64-gcc for a full GCC environment
    • mingw-w64-x86_64-pkg-config for configure
    • mingw-w64-i686-cairo for lib/cairodriver (cairo-ps.h)
    • mingw-w64-x86_64-python3-six for scripts/d.correlate
    • For 64-bit systems,
      pacman --noconfirm -S mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cairo mingw-w64-x86_64-python3-six
    • For 32-bit systems,
      pacman --noconfirm -S mingw-w64-i686-gcc mingw-w64-i686-pkg-config mingw-w64-i686-cairo mingw-w64-i686-python3-six

3   Compiling GRASS GIS

# add two export lines to ~/.bash_profile
cat <<'EOT' >> ~/.bash_profile
export LC_ALL=C
export PATH="/mingw64/bin:/c/osgeo4w64/bin:$PATH"
# for a 32-bit system
# export PATH="/mingw32/bin:/c/osgeo4w/bin:$PATH"
export PROJ_LIB="/c/osgeo4w/share/proj"

# source ~/.bash_profile
. ~/.bash_profile

mkdir -p ~/usr/local/src
cd ~/usr/local/src

# download the GRASS build scripts in ~/usr/local/src/grass-mingw-scripts
git clone

# download the GRASS source code in ~/usr/local/src/grass
git clone

cd grass

# build GRASS

# create grass79.bat in bin.x86_64-w64-mingw32 (64-bit) or bin.i686-w64-mingw32 (32-bit)

Now, grass79.bat is ready to run directly from the source directory:

  • For 64-bit systems, C:\msys64\home\USER\usr\local\src\grass\bin.x86_64-w64-mingw32\grass79.bat
  • For 32-bit systems, C:\msys64\home\USER\usr\local\src\grass\bin.i686-w64-mingw32\grass79.bat

Just run this batch file to start GRASS GIS on your machine.

4   Installing GRASS GIS on MS Windows

# package the build

Now, move to another Windows machine and extract the following ZIP file anywhere:

  • For 64-bit systems, C:\msys64\home\USER\usr\local\src\grass\
  • For 32-bit systems, C:\msys64\home\USER\usr\local\src\grass\

5   Starting GRASS GIS

You can start GRASS GIS by running grass79.bat:

  • For 64-bit systems, OSGeo4W64\opt\grass\grass79.bat
  • For 32-bit systems, OSGeo4W\opt\grass\grass79.bat

6   Latest daily build

6.1   How to install it

  1. Extract this zip file anywhere including an external drive for portability
  2. Run OSGeo4W64\opt\grass\grass79.bat

6.2   Official daily builds

Please note that this build is not an official daily build from the GRASS GIS development team. It is my personal daily build packaged as a ZIP file using This script compiles the latest master branch of the official GRASS GIS repository and packages everything GRASS GIS requires including OSGeo4W64 and Python 3.