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
- Download and run the OSGeo4W installer (osgeo4w-setup.exe)
Advanced Install
,Next
Install from Internet
,Next
C:\OSGeo4W
,Next
Next
Direct Connection
,Next
- Select a download site,
Next
- Install the following packages:
- python3-pip
- python3-wxpython
- python3-pywin32
- proj-devel
- gdal-devel
- pdal-devel
- liblas-devel
- netcdf-devel
- geos-devel
- libtiff-devel
- libpng-devel
- sqlite3-devel
- cairo-devel
- freetype-devel
- zstd-devel
Or
- Download the OSGeo4W installer (osgeo4w-setup.exe)
- Start the
cmd
window - Run the following command in the
cmd
window:osgeo4w-setup.exe -A -g -k -q -s https://download.osgeo.org/osgeo4w/v2/x86_64/ -P python3-pip,python3-wxpython,python3-pywin32,proj-devel,gdal-devel,pdal-devel,liblas-devel,netcdf-devel,geos-devel,libtiff-devel,libpng-devel,sqlite3-devel,cairo-devel,freetype-devel,zstd-devel
Install some Python modules from the OSGeo4W Shell.
# matplotlib for r.area.createweight
# scikit-learn for r.learn.ml2
# python-dateutil for t.rat.boxplot
pip install scikit-learn python-dateutil matplotlib
2 Installing MSYS2
- Download and run the MSYS2 installer (as of October 28, 2022, 64-bit installer)
Next
C:\msys64
,Next
Next
- Uncheck
Run MSYS2 64bit now
,Finish
- Run
MSYS2 MinGW 64-bit
- Install the following packages
pacman --noconfirm -S tar libintl make flex bison diffutils git dos2unix zip
- Install these packages:
- mingw-w64-x86_64-gcc for a full GCC environment
- mingw-w64-x86_64-bzip2 for configure -lbz2
- mingw-w64-x86_64-libsystre for configure -lregex
- mingw-w64-x86_64-fftw for configure -lfftw
- mingw-w64-x86_64-lapack for configure -lblas -llapack
- mingw-w64-x86_64-pkg-config for configure -lcairo -lfreetype
- mingw-w64-x86_64-dlfcn for v.feature.algebra
pacman --noconfirm -S mingw-w64-x86_64-gcc libbz2-devel mingw-w64-x86_64-libsystre mingw-w64-x86_64-fftw mingw-w64-x86_64-lapack mingw-w64-x86_64-pkg-config mingw-w64-x86_64-dlfcn
3 Compiling GRASS GIS
# add two export lines to ~/.bash_profile
cat <<'EOT' >> ~/.bash_profile
export LC_ALL=C
# for OSGeo4W
export PATH="/c/osgeo4w/bin:/mingw64/bin:$PATH"
export PROJ_LIB="/c/osgeo4w/share/proj"
export PYTHONHOME="/c/osgeo4w/apps/python39"
EOT
# 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 https://github.com/HuidaeCho/grass-mingw-scripts.git
# download the GRASS source code in ~/usr/local/src/grass
git clone https://github.com/OSGeo/grass.git
cd grass
# build GRASS
../grass-mingw-scripts/myconfigure.sh
../grass-mingw-scripts/mymake.sh
# create grass.bat in bin.x86_64-w64-mingw32
../grass-mingw-scripts/mkbats.sh
Now, grass.bat
is ready to run directly from the source directory C:\msys64\home\USER\usr\local\src\grass\bin.x86_64-w64-mingw32\grass.bat
. Just run this batch file to start GRASS GIS on your machine.
4 Installing GRASS GIS on MS Windows
# package the build
../grass-mingw-scripts/package.sh
Now, move to another Windows machine and extract the following ZIP file anywhere: C:\msys64\home\USER\usr\local\src\grass\grass80-x86_64-w64-mingw32-osgeo4w64-YYYYMMDD.zip
5 Starting GRASS GIS
You can start GRASS GIS by running OSGeo4W\opt\grass\grass.bat
.
6 Changing the default shell
To change the default shell from cmd.exe
to something else, define a new environment variable called GRASS_SH
:
- Control Panel
- User Accounts
- Change my environment variables
- Add a new user variable
GRASS_SH=powershell
(your choice of a shell) - Start
grass.bat
If you want a bash-like shell, download busybox64.exe as C:\bin\sh.exe
and set GRASS_SH=C:\bin\sh.exe
.
7 Latest daily build
- grass84-x86_64-w64-mingw32-osgeo4w64-latest.zip (permanent link for the latest build)
- latest build log
- grass84-x86_64-w64-mingw32-osgeo4w64-20240327.zip
- version: 8.4.0dev (2024) 17dac199ea
- sha256sum: 7de38c926f7dc02f948fe221e060fa1e353eb49c1ffcf4a5dddfc3b809d46c5f
- file size: 1.1G
7.1 How to install it
- Extract this zip file anywhere including an external drive for portability
- Run
OSGeo4W\opt\grass\grass.bat
7.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 compile.sh
. This script compiles the latest main branch of the official GRASS GIS repository and packages everything GRASS GIS requires including OSGeo4W and Python 3.