How to cross-compile GRASS GIS for MS Windows
This page explains how to cross-compile portable GRASS GIS for MS Windows using these scripts.
See also How to compile GRASS GIS on MS Windows.
1 Building a cross-compiling environment using MXE
The very first step for any cross-compilation project is to set up a cross-compiling environment. I found the MXE (M cross environment) to be very easy to set up. However, some packages are slightly outdated. For example, GDAL is 2.2.4 and PROJ is 5.1.0, but GRASS still supports these versions.
# myconfigure.sh looks for the MXE root in ~/usr/local/src/mxe by default, # but you can change this path here and in ~/.grassbuildrc later. mkdir -p ~/usr/local/src cd ~/usr/local/src # download MXE in ~/usr/local/src/mxe git clone https://github.com/mxe/mxe.git cd mxe # build MXE packages required for GRASS GIS echo MXE_TARGETS=x86_64-w64-mingw32.shared > settings.mk make cc blas bzip2 cairo fftw freetype gdal geos lapack netcdf libpng pthreads readline libgnurx sqlite tiff zstd proj
2 Compiling native GRASS GIS first
You need to compile native GRASS GIS first because many document files are generated by binary modules, but cross-compiled binaries cannot be executed.
mkdir -p ~/usr/local/src cd ~/usr/local/src # download the GRASS build scripts in ~/usr/local/src/grass-build-scripts git clone https://github.com/HuidaeCho/grass-build-scripts.git # download the GRASS source code in ~/usr/local/src/grass git clone https://github.com/OSGeo/grass.git cd grass-build-scripts # copy ~/usr/local/src/grass-build-scripts/.grassbuildrc-example to ~/.grassbuildrc cp .grassbuildrc-example ~/.grassbuildrc # you can change paths in ~/.grassbuildrc, but this page will use the default ones vi ~/.grassbuildrc # build native GRASS ./myconfigure.sh ./mymake.sh
3 Cross-compiling GRASS GIS
# cross-compile GRASS for MS Windows ./myconfigure.sh --mxe ./mymake.sh # copy document files from the native build ./copydocs.sh # post-process the cross-compiled build; # make sure to set up PYTHON_WINDIR in ~/.grassbuildrc correctly before running this script ./postcompile.sh
Now, you should have the
~/usr/local/src/grass/dist.x86_64-w64-mingw32 directory ready to be deployed.
4 Installing GRASS GIS on MS Windows
# package the cross-compiled build ./package.sh
Now, move to your Windows machine and extract
5 Installing Python 3.8
Install Python 3.8 anywhere with the
Add Python 3.8 to PATH option checked.
grass\grass79.bat will try to detect
python.exe automatically within
PATH. If you don’t want to use the auto-detection feature for any reasons (
python.exe not in
PATH, multiple Python installations, or you just don’t like it), you can set
grass\grass79.bat to override this feature. By default, this variable is set to
C:\Python38\python.exe, but you don’t have to change it even if your Python is installed somewhere else. Python will still be detected as long as you checked the
Add Python 3.8 to PATH option.
If you uncheck
Install launcher for all users (recommended), it won’t require administrative rights.
Once Python is installed, open the
cmd window and install required modules:
pip3 install six wxPython pywin38
If you want to make GRASS GIS portable with Python installed on the same external drive, you cannot rely on PATH or use a fixed drive letter. Use
%~d0 for the changing drive letter in
grass\grass79.bat. For example,
6 Starting GRASS GIS
You can start GRASS GIS by running
grass\grass79.bat. Or copy-paste
grass79.lnk to create a shortcut, but make sure to change its target and start-in paths to yours.
7 Latest daily build
- grass79-x86_64-w64-mingw32-latest.zip (permanent link for the latest build)
- latest log file
- version: 7.9.dev (2020) a3888a00d
- sha256sum: 845d18feabe3e69bf28791563a71e8dd31507fa1f6a527f8d96b7189cbebe846
- file size: 129M
7.1 How to install it
- Extract this zip file anywhere including an external drive for portability
- Install Python 3.8 (see above)
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
crosscompile.sh. This script compiles the latest master branch of the official GRASS GIS repository.