Repository for Ideas & Research
Open Source GIS, Hydrologic Modeling, Optimization

How to compile GRASS GIS on MS Windows

There is a great wiki page that explains step-by-step procedures on how to compile GRASS GIS on MS Windows, but it requires the installation of Visual Studio 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.

1   Install OSGeo4W

  1. Download and run the OSGeo4W installer (32-bit or 64-bit)
  2. Advanced Install, Next
  3. Install from Internet, Next
  4. C:\OSGeo4W (32-bit) or C:\OSGeo4W64 (64-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
    • 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

2   Install MSYS2

  1. Download and run the MSYS2 installer (as of July 9, 2019, 32-bit or 64-bit)
  2. Next
  3. C:\msys32 (32-bit) or C:\msys64 (64-bit), Next
  4. Next
  5. Uncheck Run MSYS2 32bit now (32-bit) or Run MSYS2 64bit now (64-bit), Finish
  6. Run MSYS2 MinGW 32-bit (32-bit) or MSYS2 MinGW 64-bit (64-bit)
  7. Install the following packages (both 32-bit and 64-bit)
    pacman -S tar libintl make bison diffutils git dos2unix zip
  8. Install these packages
    • 32-bit:
      pacman -S mingw-w64-i686-toolchain mingw-w64-i686-cairo mingw-w64-i686-python3-numpy mingw-w64-i686-python3-six mingw-w64-i686-sqlite3 mingw-w64-i686-xz mingw-w64-i686-lz4
    • 64-bit:
      pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-python3-numpy mingw-w64-x86_64-python3-six mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-xz mingw-w64-x86_64-lz4

3   Compile GRASS GIS

  1. Add two export lines to ~/.bash_profile by running
    • 32-bit:
      cat <<EOT >> ~/.bash_profile
      export LC_ALL=C
      export PATH="$PATH:/c/osgeo4w/bin"
      EOT
    • 64-bit:
      cat <<EOT >> ~/.bash_profile
      export LC_ALL=C
      export PATH="$PATH:/c/osgeo4w64/bin"
      EOT
  2. Source ~/.bash_profile
    . ~/.bash_profile
  3. Checkout the GRASS GIS Git repository
    mkdir -p ~/usr/grass
    cd ~/usr/grass
    git clone https://github.com/OSGeo/grass.git
  4. Download myconfigure.sh, mymake.sh, and mkbats.sh in ~/usr/grass
  5. Configure and compile GRASS GIS
    cd ~/usr/grass/grass
    ../myconfigure.sh
    ../mymake.sh
  6. Create batch files for MS Windows in ~/usr/grass/bin
    ../mkbats.sh
  7. Create a shortcut to C:\msys64\home\USERNAME\usr\grass\bin\grass77.bat and change the icon to C:\msys64\home\USERNAME\usr\grass\grass\mswindows\grass.icon

References

Please leave this field blank: