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 (64-bit or 32-bit)
Advanced Install
,Next
Install from Internet
,Next
C:\OSGeo4W64
(64-bit) orC:\OSGeo4W
(32-bit),Next
Next
Direct Connection
,Next
- Select a download site,
Next
- 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
- 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
Or
- Download the OSGeo4W installer (64-bit or 32-bit)
- Start the
cmd
window - Run the following command in the
cmd
window:- For 64-bit systems,
osgeo4w-setup-x86_64.exe -A -g -k -q -s http://download.osgeo.org/x86_64 -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 http://download.osgeo.org/x86 -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
- For 64-bit systems,
2 Installing MSYS2
- Download and run the MSYS2 installer (as of July 9, 2019, 64-bit or 32-bit)
Next
C:\msys64
(64-bit) orC:\msys32
(32-bit),Next
Next
- Uncheck
Run MSYS2 64bit now
(64-bit) orRun MSYS2 32bit now
(32-bit),Finish
- Run
MSYS2 MinGW 64-bit
(64-bit) orMSYS2 MinGW 32-bit
(32-bit) - Install the following packages (both 64-bit and 32-bit)
pacman --noconfirm -S tar libintl make bison diffutils git dos2unix zip
- 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"
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 grass79.bat in bin.x86_64-w64-mingw32 (64-bit) or bin.i686-w64-mingw32 (32-bit)
../grass-mingw-scripts/mkbats.sh
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
../grass-mingw-scripts/package.sh
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\grass79-x86_64-w64-mingw32-osgeo4w64-YYYYMMDD.zip
- For 32-bit systems,
C:\msys64\home\USER\usr\local\src\grass\grass79-i686-w64-mingw32-osgeo4w64-YYYYMMDD.zip
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
- grass79-x86_64-w64-mingw32-osgeo4w64-latest.zip (permanent link for the latest build)
- latest log file
- grass79-x86_64-w64-mingw32-osgeo4w64-20210123.zip
- version: 7.9.dev (2021) ceaa57016
- sha256sum: 23c26bdfedccebf7c85c51a11187bac6be26f3e9ddc34aca6a0f24ffb39fe520
- file size: 356M
6.1 How to install it
- Extract this zip file anywhere including an external drive for portability
- 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 compile.sh
. This script compiles the latest master branch of the official GRASS GIS repository and packages everything GRASS GIS requires including OSGeo4W64 and Python 3.