Version 385 (modified by martinl, 9 months 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
  1. Run the installer.
osgeo4w-setup -g -k -a x86_64 -q -P proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,pdal-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,python3-six,python3-wxpython,regex-devel,wxwidgets-devel,zstd-devel
=== 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.

2. Start MSYS2 terminal and install requirements:

pacman -S tar libintl make bison diffutils git dos2unix zip

3. Install MinGW-w64 toolchain:

pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-xz mingw-w64-x86_64-lz4 mingw-w64-x86_64-fftw

4. 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/` should look like:

PROGRAMFILES="/c/Program Files (x86)"
VSDIR="$PROGRAMFILES/Microsoft Visual Studio 14.0"

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/` may look like:

PROGRAMFILES="/c/Program Files (x86)"
VSDIR="$PROGRAMFILES/Microsoft Visual Studio/2017/Community"
== Compiling and Installing GRASS GIS ==

Start '''MSYS2''' terminal.

1. Download GRASS source code (see wiki:DownloadSource for details). Example for development version (main branch):

cd /usr/src
git clone grass

2. Switch to GRASS GIS source code directory (in our case `grass`) and run `` compilation script:

cd grass

# for release builds
OSGEO4W_ROOT_MSYS=/c/osgeo4w ./mswindows/osgeo4w/

# for daily builds
OSGEO4W_ROOT_MSYS=/c/osgeo4w PACKAGE_POSTFIX=-daily ./mswindows/osgeo4w/

3. 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\}}}.

=== 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):


== Creating a WinGRASS Installer ==

The instructions for creating a WinGRASS native installer (self-contained package installer) using the scripts contained in the [source:grass/trunk/mswindows 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 [source:grass-addons/tools/wingrass-packager 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 [wiki:HowToTestGrass6 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}}}.

2. Launch the file {{{c:\temp\GRASS-Packager.bat}}}.

4. 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]

2. Install to {{{c:\DevTools}}}

=== Install NSIS: Untgz Plugin ===

1. Download the [ NSIS Untgz Plugin]

2. Copy {{{untgz.dll}}} to {{{c:\DevTools\Plugins}}}

=== Install NSIS: !AccessControl Plugin ===

1. Download the [ NSIS AccessControl Plugin]

2. Unzip to {{{c:\DevTools\}}}
=== Create the WinGRASS Installer ===

1. Launch {{{c:\temp\GRASS-Installer.nsi}}}.

2. When finished, you should have the WinGRASS installer in {{{c:\temp}}}.

== Misc ==

=== LibreDWG ===

Required by GRASS Addons [source:grass-addons/grass7/vector/].

 1. Download

TODO: Finish this part.

=== WinGRASS 64bit Notes ===

External notes for building windows 64bit-binaries:

 * [ OSGeo4W-64bit inital notes]
 * [ GRASS changes for OSGeo4W 64bit]
 * [ Building R for 64-bit Windows]
 * [ Building SpatiaLite for 64-bit Windows]
 * [ gvSIG and MinGW-w64 (C/C++ compiler)]
 * [ recipe used to build GRASS 6.4.3 on OSGeo4W in 64bit]

Tool chains for building windows 64bit-binaries:

 * [ MinGW-w64 - GCC for both 64 & 32 bits Windows]
 * [ TDM-GCC - A compiler suite for 32- and 64-bit Windows based on the GNU toolchain]
 * [ Native windows x64 software develop with Mingw-w64]

== Hints ==

=== Startup errors after installation ===

See here:

=== See also ===

 * [ GRASS package page in OSGeo4W] (including [ packaging notes])
 * [wiki:BuildingOnWindows Develop your own GRASS modules on MS-Windows]
 * by QGIS Team
 * by Marco Pasetti
 * by Marco Pasetti

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

 * see also [ OSGeo4W pkg-grass buglist]

 * 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:'''

'''winGRASS 7:'''

Note: See TracWiki for help on using the wiki.