wiki:CompileOnWindows

Version 358 (modified by hellik, 5 years ago) ( diff )

--

Compiling GRASS on MS-Windows

Dependencies required for building with MinGW

Compiling your own copy of GRASS is greatly simplified by using the MSYS2 and OSGeo4W directory structure to install most dependencies and downloading the rest from a few other locations. Follow the steps below to set up the build environment for GRASS GIS.

Install the OSGeo4W directory structure

OSGeo4W has several of the required dependencies for compiling GRASS GIS:

  1. Download the OSGeo4W installer - 32bit or 64bit
  1. Run the installer.
  1. Select Advanced Install, and Next.
  1. Set the install directory to C:\OSGeo4W (32bit) or C:\OSGeo4W64 (64bit) (other directories are fine if there are no spaces in the path but make sure to adjust the instructions below). The MSYS maintainers have made it clear that they will not support spaces in path names nor accept patches fixing those issues. With some patches to msys.bat however it is possible to install a built GRASS into C:\Program Files\.
  1. Select:
    • cairo
    • gdal
    • geos
    • fftw
    • fftw-devel (32bit only)
    • freetype-devel
    • freetype-devel-mingw (32bit only)
    • iconv
    • libjpeg
    • liblas-devel
    • libpng
    • libpq
    • libtiff
    • libxdr
    • pdcurses
    • proj
    • regex-devel
    • sqlite3
    • zlib
    • zstd-devel, zstd
  1. Optionally select also GDAL plugins for common GIS formats (be careful not to introduce GPL incompatibilities)
    • gdal-ecw
    • gdal-mrsid
  1. Click Next, the selected packages and their required subpackages will be downloaded and installed automatically.

Install the MSYS2 directory structure

MSYS2 has several of the required dependencies for compiling GRASS GIS (like gcc and others):

  1. Download and install MSYS2.
  1. Start MSYS2 terminal and install requirements (both 32bit and 64bit):
pacman -S tar libintl make bison diffutils git dos2unix zip
  1. Install MinGW-w64 toolchain:
  • 32bit:
    pacman -S mingw-w64-i686-toolchain mingw-w64-i686-cairo mingw-w64-i686-python2-numpy mingw-w64-i686-sqlite3 mingw-w64-i686-xz mingw-w64-i686-lz4 mingw-w64-i686-python3-numpy mingw-w64-i686-python3-six
    
  • 64-bit:
    pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-python2-numpy mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-xz mingw-w64-x86_64-lz4 mingw-w64-x86_64-python3-numpy mingw-w64-x86_64-python3-six
    
  1. Add to C:\msys{32|64}\home\user\.bashrc
export LC_ALL=C

Optional dependecies

Part of packaging process is also producing VC libraries using dumpbin command which is part of Visual Studio framework. It's recommended to install Common Tools for Visual C++ (e.g. in Microsoft Visual Studio 14.0).

In this case, following lines in the source file mswindows/osgeo4w/mklibs.sh should look like:

PROGRAMFILES="/c/Program Files (x86)"
VSDIR="$PROGRAMFILES/Microsoft Visual Studio 14.0"
PATH="$VSDIR/Common7/IDE:$PATH"
PATH="$VSDIR/VC/bin:$PATH"
PATH="$VSDIR/Common7/Tools:$PATH"
PATH="$PATH:/c/OSGeo4W${OSGEO4W_POSTFIX}/bin"

In newer MS Visual Studio versions, Visual Studio Community can be installed instead.

In the case of newer MS Studio versions (e.g. 2017 on 64 bit platform), following lines in the source file mswindows/osgeo4w/mklibs.sh may look like:

PROGRAMFILES="/c/Program Files (x86)"
VSDIR="$PROGRAMFILES/Microsoft Visual Studio/2017/Community"
PATH="$VSDIR/Common7/IDE:$PATH"
PATH="$VSDIR/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64:$PATH"
PATH="$VSDIR/Common7/Tools:$PATH"
PATH="$PATH:/c/OSGeo4W${OSGEO4W_POSTFIX}/bin"

Compiling and Installing GRASS GIS

Start MSYS2 terminal - mingw32_shell.bat (32bit) or mingw64_shell.bat (64bit).

  1. Download GRASS source code (see wiki:DownloadSource for details). Example for development version (trunk):
cd /usr/src
git clone https://github.com/OSGeo/grass grass_master
  1. Switch to GRASS GIS source code directory (in our case grass_trunk) and run package.sh compilation script:
cd grass_master

# for release builds on 32bit
./mswindows/osgeo4w/package.sh

# for daily builds on 32bit
PACKAGE_POSTFIX=-daily ./mswindows/osgeo4w/package.sh

# for release builds on 64bit
OSGEO4W_POSTFIX=64 ./mswindows/osgeo4w/package.sh

# for daily builds on 64bit
PACKAGE_POSTFIX=-daily OSGEO4W_POSTFIX=64 ./mswindows/osgeo4w/package.sh
  1. Check error.log for any error messages and mswindows/osgeo4w/package.log if you're having problems.

GRASS GIS should now be installed in c:\osgeo4w\apps\grass\grass-7.7.svn.

Usage

To start GRASS use the icon on the desktop or if you want to be able to use the command line from within GRASS.

Type in the OSGeo4W cmd console (assuming that we compiled GRASS 7.6):

c:\osgeo4w\bin\grass76svn.bat

Creating a WinGRASS Installer

The instructions for creating a WinGRASS native installer (self-contained package installer) using the scripts contained in the mswindows directory. In order to avoid mistakes or misunderstandings, we highly recommend to follow each step and command exactly as they are written in this document. See also scripts used for daily builds.

Install MSYS2/OSGeo4W Tree and Compile GRASS

First of all download the MSYS2, OSGeo4W installers, install the required dependencies, and build GRASS GIS from source (see notes above). Do not move on to step two until you have successfully tested your new version of GRASS.

Create a GRASS self-contained Package

  1. Copy all the content of the mswindows directory to a temporary directory, for example c:\temp.
  1. Launch the file c:\temp\GRASS-Packager.bat.
  1. When finished, you should have a GRASS self-contained release package in c:\temp\GRASS-<Version>-Package, e.g. c:\temp\GRASS-70-Package.

Install NSIS

  1. Download the NSIS installer
  1. Install to c:\DevTools

Install NSIS: Untgz Plugin

  1. Download the NSIS Untgz Plugin
  1. Copy untgz.dll to c:\DevTools\Plugins

Install NSIS: AccessControl Plugin

  1. Download the NSIS AccessControl Plugin
  1. Unzip to c:\DevTools\

Create the WinGRASS Installer

  1. Launch c:\temp\GRASS-Installer.nsi.
  1. When finished, you should have the WinGRASS installer in c:\temp.

Misc

LibreDWG

Required by GRASS Addons v.in.redwg.

  1. Download http://www.gnu.org/software/libredwg/

TODO: Finish this part.

WinGRASS 64bit Notes

External notes for building windows 64bit-binaries:

Tool chains for building windows 64bit-binaries:

Hints

Startup errors after installation

See here: http://grass.osgeo.org/wiki/WinGRASS_errors

See also

  • Besides Cygwin and MinGW there is another along similar lines called "som" or "gow" or something?

Errata

  • Some anti-virus software seem to think that the r.out.png.exe module (etc.) is a sneaky attempt to fool you into thinking it's an image instead of what it really is: a program which exports a PNG file. g.version is also reported to set them off. You'll have to bypass these over-zealous warnings as appropriate.

Open Tickets

winGRASS 6:

#226
WinGRASS fails to create .gislock opening a mapset
#508
hardcoded /dev/null
#573
stanalone installer: include the release notes
#606
WinGRASS GIS.m: broken newlines in output window
#805
i.spectral in GRASS6.4
#820
r.in.wms doesn't work in WinGRASS installer distribution
#966
wx attribute table manger fails on wingrass with >188 dbf tables
#984
v.out.ogr to MySQL does not work propely
#1005
db.out.ogr together with g.parser doesn't play nicely with non-lati characters containing DSN
#1042
winGRASS: r.statistics complains if path to grassdb has spaces
#1053
After abort command v.surf.rst from wxGUI vector output of devation (devi) couldn´t be removed, or overwrited
#1166
r.tileset: projection string munching on wingrass
#1182
.inputrc improving msys WinGRASS command line
#1193
Python Menu: Japanese (double byte character) in menu may cause parser error.
#1235
ERROR: G_getenv(): Variable LOCATION_NAME not set
#1282
WinGrass using www.python.org-installation
#1290
WinGrass: v.krige not working due to missing rpy2 pkg for MS Windows
#1447
wxGUI wingrass scripts need whitespace in path
#1514
wingrass - different wingrass-modes are differently translated
#1556
wingrass - g.message in a python-script - no output
#1664
Texts in command dialogs are garbled
#1891
wingrass: background dosbox from regular wxgui startup
#1945
wingrass: Command Line can't find grass.python libs
#1952
wingrass: please add tac and seq to extrabin
#1953
wingrass: GRASS6\wx file has \r\r\n newline
#1959
wingrass wx carto composer: Image causes traceback
#1962
wingrass installer: install_msruntime dir not deleted despite rule for it
#1964
m.proj on wingrass: protect g.proj's path name to the grid file
#2215
wxGUI file type option. File path corrupt if contained backslash
#2390
Command console is crashing if any system user name contains accented character
#2755
Commandline switch "/S" is not working anymore
#2890
wxGUI.PsMap error loading two types north arrow and grass gis logo in the cartographic composer layout
#3047
MySQL driver failed to install
#3156
Cannot export GRASS raster map using r.out.png (crashes on windows)
#3408
r.tileset fails on windows due to permissions error
#3548
sql where statement encoding issue on windows
#3655
Add PDAL to standalone GRASS GIS install
#3855
update WinGRASS standalone installer to use GRASS_VERSION_GIT variable
#3925
winGRASS 7.8.1dev: 'charmap' codec can't decode byte 0x9d - issue in vector attribute data handling (e.g. opening attribute table, v.report, etc)

winGRASS 7: No results

Note: See TracWiki for help on using the wiki.