Table of Contents
Compiling GRASS on MS-Windows
Dependencies required for building with MinGW
Compiling your own copy of GRASS is greatly simplified by using the 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.
Install the OSGeo4W directory structure
OSGeo4W has several of the required dependencies for compiling GRASS:
1. Download the OSGeo4W installer from here.
2. Run the installer.
3. Select Advanced Install, and Next.
4. Set the install directory to c:\OSGeo4W (other directories or 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\.
5. Select grass from the desktop section (this is a binary but we'll compile from source later).
6. Also select:
- Commandline_Utilities
- avce00
- gpsbabel
- Libs:
- fftw-devel
- freetype-devel
- freetype-devel-mingw
- gsl-libs
- gsl-devel
- libpng-devel
- libpng-devel-mingw
- libtiff-devel
- libxdr
- mingw-libs (contains mingw-style libraries for VC build binaries and depends on gdal, libpq, libjpeg-devel, sqlite3, libtiff, zlib, proj)
- pdcurses-devel
- tcltk-devel
- zlib-devel
7. Click next, the selected packages and their required subpackages will be downloaded and installed automatically.
Install the environment for compilation (MingW)
1. Run msys (there should be an icon on the desktop)
- Note for Vista 64bit: in case that MSYS starts to open multiple windows, close them all. Check first this discussion. A solutions seems to be to download http://downloads.sourceforge.net/mingw/msysCORE-1.0.11-bin.tar.gz (or newer?). Open the tarball, and copy the bin directory over C:\osgeo4w\apps\msys\bin. see also https://sourceforge.net/forum/forum.php?forum_id=720513
2. Type:
mkdir /c/osgeo4w/apps/msys/osgeo4w
3. Copy c:\osgeo4w\apps\msys\etc\fstab.sample to c:\osgeo4w\apps\msys\etc\fstab (without .sample)
cd /c/OSGeo4W/apps/msys/etc/ cp fstab.sample fstab
4. Open c:\osgeo4w\apps\msys\etc\fstab
5. At line 16, change:
c:/mingw /mingw c:/ActiveState/perl /perl
To:
c:/osgeo4w/ /osgeo4w
6. Download the MinGW packages: (updates may be found here)
- Temp bugfix (see here), msysCORE-1.0.11-bin from here
- bin-utils from here
- gcc-core from here
- gcc-g++ from here
- mingw32-make from here
- mingw-runtime from here
- mingw-utils from here
- w32api from here
7. Unpack all to c:\osgeo4w
8. Download the latest make program compliant with the OSGeo4W framework from here (future updates may be found here)
9. Unpack to c:\osgeo4w\apps\msys
10. Close and re-open msys to reload the settings.
Pre-built Binaries
Download: (updates may be found here)
- bison from here
- bison-deps from here
- flex from here
- gettext-bin from here
- gettext-lib from here
- libiconv-lib from here
- libintl-bin from here
- libintl-lib from here
- regex from here
- bc from here
- readline from here
Unpack all to c:\osgeo4w
Compiling and Installing GRASS (6.4.0)
1. Download the latest weekly snapshot GRASS 6.4.0 source code from here (for latest SVN version, see below)
2. Unpack to c:\osgeo4w\usr\src
3. To compile, type in MSYS console:
cd /osgeo4w/usr/src/grass-6.4xxx (change to dir of the version you downloaded) ./mswindows/osgeo4w/package.sh
4. Check error.log for any error messages and mswindows/osgeo4w/package.log if you're having problems.
GRASS should now be installed in c:\osgeo4w\apps\grass\grass-6.4.0
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
1. Type in MSYS console:
/osgeo4w/apps/grass/bin/grass64
Or to use the new wxpython GUI:
/osgeo4w/apps/grass/bin/grass64 -wxpython
Compiling and Installing Development Versions of GRASS
Optional Installation of Subversion
The GRASS source tree is stored in an online repository called Subversion. Rather than downloading source trees from the website, Subversion lets you keep up to date, and manage your modifications, with simple commands or a graphical tool. For details, see here.
A) Command line based:
- Download Collabnet Subversion Command-Line Client (1.6) from here. (You'll have to register on Collabnet)
- Run the subversion installer and install it to a path without spaces such as c:/Subversion
- Open c:\osgeo4w\etc\ini\msys.bat and at line 1 add the path to your subversion folder, e.g. change:
PATH %PATH%;%OSGEO4W_ROOT%\apps\msys\bin
to:PATH %PATH%;%OSGEO4W_ROOT%\apps\msys\bin;/c/Subversion
B) Graphical user interface based:
Alternatively, get TortoiseSVN, a plugin for Windows Explorer, which can be used for managing the local source tree. Download here.
Grass-6.4.svn (releasebranch_64)
1. Download the grass-6.4.svn source tree with:
- Subversion (also see here)
cd /osgeo4w/usr/src svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/ grass64_release cd /osgeo4w/usr/src/grass64_release
OR
- Download a weekly snapshot from here and unpack to /osgeo4w/usr/src
2. See below for compilation and installation.
3. After installation, start with:
/osgeo4w/apps/grass/bin/grass64
Grass-6.5.svn (develbranch_6)
1. Download the grass-6.5.svn source tree with:
- Subversion (also see here)
cd /osgeo4w/usr/src svn co https://svn.osgeo.org/grass/grass/branches/develbranch_6/ grass6_devel cd /osgeo4w/usr/src/grass6_devel
OR
- Download a weekly snapshot from here
2. See below for compilation and installation.
3. After installation, start with:
/osgeo4w/apps/grass/bin/grass65
Grass-7.0.svn (trunk)
1. Download the grass-7.0.svn source tree with:
- Subversion (also see here)
cd /osgeo4w/usr/src svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk cd /osgeo4w/usr/src/grass_trunk
OR
- Download a weekly snapshot from here
2. Open c:\osgeo4w\etc\ini\msys.bat and at line 3 add:
set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python25
3. See below for compilation and installation.
4. After installation, start with:
/osgeo4w/apps/grass/bin/grass70
Compiling and Installing
To compile, type in MSYS console:
./mswindows/osgeo4w/package.sh
To update your source tree later using subversion and recompile type:
make distclean svn up rm mswindows/osgeo4w/configure-stamp ./mswindows/osgeo4w/package.sh
Troubleshooting
Here are a few common problems and their solutions:
| With module... | If you get the error | Do the following |
| r.mapcalc, r.univar, or raster3d/base | No rule to make target ... needed by 'progs' | Update msys's make (see step 8 in the MinGW section above) |
| scripts/* | ImportError: No module named grass | Fix PYTHONPATH to *nix-style (eg. PYTHONPATH=/osego4w/apps/Python25) |
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.
Install OSGeo4w Tree and Compile GRASS
First of all download the OSGeo4W installer, install the required dependencies, and build GRASS from source. 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.
2. Edit file c:\temp\GRASS-Packager.bat to reflect the paths to your OSGeo4W tree and the GRASS version being packaged. Default settings is:
set OSGEO4W_DIR=c:\osgeo4w set GRASS_64_RELEASE_INSTALL_FOLDER=%OSGEO4W_DIR%\apps\grass\grass-6.4.0 set GRASS_64_DEV_INSTALL_FOLDER=%OSGEO4W_DIR%\apps\grass\grass-6.4.0svn set GRASS_65_DEV_INSTALL_FOLDER=%OSGEO4W_DIR%\apps\grass\grass-6.5.svn
3. Launch the file c:\temp\GRASS-Packager.bat and select version to be packaged.
4. When finished, you should have a GRASS self-contained release package in c:\temp\GRASS-<Version>-<Release/Dev>-Package, e.g. c:\temp\GRASS-64-Release-Package.
Remove OSGeo4W Traces from Package
1. Open c:\temp\GRASS-Release-Package\msys\msys.bat and remove lines 11-16.
2. At the end of line 88 (also in msys.bat) change:
start %WD%rxvt -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -c "%*"
To:
if "x%*" == "x" start "MSYS 1.0" "%WD%rxvt" -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -i if NOT "x%*" == "x" start "MSYS 1.0" "%WD%rxvt" -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -c "%*"
Install NSIS (2.45)
1. Download the NSIS installer
2. Install to c:\DevTools
Install NSIS: Untgz Plugin (1.0.16)
1. Download the NSIS Untgz Plugin
2. Unzip to c:\DevTools\Plugins\
Create the WinGRASS Installer
1. Edit file c:\temp\GRASS-Installer.nsi to reflect path to the GRASS source tree. Default settings is:
!define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass64_release\demolocation" !define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass6_devel\demolocation"
2. Define INSTALER_TYPE
- GRASS 6.4: valid options - Release64, Dev64 (default: Release64)
- GRASS 6.5: valid options - Dev65 (default: Dev65)
- GRASS 7.0: valid options - Dev7 (default: Dev7)
3. Update SVN revision number (see svn info), e.g. change
!define DEV65_SVN_REVISION "36599"
to
!define DEV65_SVN_REVISION "40505"
4. Right click on the file c:\temp\GRASS-Installer.nsi and select Compile NSIS Script.
5. When finished, you should have the WinGRASS release installer in c:\temp.
TODO
- QGIS
- Add cairo support to grass-7.0.svn
- Add geos support for grass-7.0.svn (need geos-config file)
Building with MS Visual Studio
Hints
Changing the user interface locale
- MSys users should be setting the LANG, LC_MESSAGES etc. variables in ~/.bash_profile (etc) if they want it set to a specific locale other than the default locale.
See also
- GRASS package page in OSGeo4W (including packaging notes)
- Develop your own GRASS modules on MS-Windows
- http://wiki.qgis.org/qgiswiki/BuildingFromSource by QGIS Team
- http://www.webalice.it/marco.pasetti/grass/BuildFromSource.html by Marco Pasetti
- http://www.webalice.it/marco.pasetti/qgis+grass/BuildFromSource.html by Marco Pasetti
Errata
- see also OSGeo4W pkg-grass buglist
- r.patch and v.patch do not work on 32bit Vista. They exit with a "Bad file number" error. Apparently Windows's security measures think that "patch" is a dangerous word. (see bug #759)
- Solution 1: Switch off UAC.
- Solution 2: Rename C:\GRASS\bin\r.patch.exe to r.fuzzy_kittens.exe. Do something similar for v.patch.exe. To keep the menus working you will want to edit the C:\GRASS\etc\wxpython\xml\menudata.xml file as well to match the new names.
- Similarly, 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 a program which exports a PNG file. g.version is also reported to set them off. You'll have to bypass those over-zealous warnings as appropriate.
- Large File support ("LFS", >2GiB) is currently not supported for 32bit versions of Windows. A 64bit build of GRASS (or more accurately a build of the support libraries needed to build 64bit GRASS) is still in development.
Open Tickets
- #111
- r.los fails with high values for max_dis parameter
- #142
- WinGRASS Native: Ground Control Points Usability
- #226
- WinGRASS fails to create .gislock opening a mapset
- #508
- hardcoded /dev/null
- #534
- g.gui doesn't work in ms-windows
- #555
- v.in.gpsbabel on wingrass: g.proj error
- #575
- stanalone installer: permission denied on mdoule execution
- #585
- init.bat should give usage info with --help
- #606
- WinGRASS GIS.m: broken newlines in output window
- #617
- r.sim.water crashes on WinGrass
- #627
- wingrass native: wxNVIZ exits with lib compat error
- #628
- wingrass native: vdigit error on new map
- #653
- consider using console instead of cmd.exe
- #711
- r.horizon crashes
- #713
- OSGeo4W patch for g3d lib
- #715
- OSGeo4W patch for DLLs
- #740
- v.edit returns incorrect results on Windows
- #759
- r.patch non-functional in WinGRASS 6.4 svn on Vista
- #811
- MYSYS shortcut starts an infinite number of windows
- #813
- Location wizard - false path to the epsg-file
- #827
- standalone-installer: execution failed on g.proj.exe -p
- #843
- v.digit broken on new WinGrass release
- #856
- r.proj fails in WinGRASS-6.4.0SVN-r40049-1
- #889
- Msys-based commands fail when winGRASS is installed in %ProgramFiles%
- #890
- shell scripts: %TMP% namespace collision
- #894
- wingrass uninstaller: left over files
- #897
- WinGrass: error with "Query vector map (edit mode)"
- #898
- WinGrass: r.out.xyz error
- #908
- No Font Definition File, windows xp
- #917
- v.digit map creation weirdness on wingrass
Closed Tickets
- #65
- WinGRASS: Starting up gis.m & hangs (probably on g.region)
- #118
- r.patch fails on Vista
- #162
- r.regressionline incompatability issue in WinGRASS
- #234
- v.type, v.type.sh, GUI and WinGRASS
- #363
- WinGRASS: Accsess Denied in .grassrc6
- #478
- MSYS Console fails to start when installed in Windows at a path with spaces.
- #499
- fresh windows startup not very friendly
- #559
- wingrass stand-alone installer: MSys console doesn't work
- #570
- startup problem with standalone winGRASS install and custom python
- #580
- WinGRASS: $GISBASE/etc/gui/scripts/ require something like $(EXE) to run
- #586
- WinGRASS: 3D view wxNVIZ does not work
- #588
- wxGUI: About GRASS GIS window doesn't let you view full lic or devs
- #593
- WinGRASS GIS.m: cannot select maps from mapset GUI
- #595
- WinGRASS g.version -c fails
- #629
- WinGRASS: spaces in pathnames
- #634
- v.out.ogr error on Vista
- #637
- Problems with paths in the TCL/TK Windows GUI
- #639
- Wingrass native r.in.aster doesn't work
- #655
- g.manual fails to open a browser
- #736
- r.proj fails in wingrass
- #744
- package.sh for compiling on windows
- #783
- r.watershed fails on wingrass
- #786
- Update to http://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/mswindows/README.html
- #806
- WinGRASS: Problem with special characters (wxpython GUI)
- #809
- v.db.addtable consistently fails in winGrass
- #877
- wxGUI: Location wizard bug when creating LatLong location
- #878
- v.external not working on WinGrass
- #881
- winGRASS compilation: dumpbin: command not found
- #882
- i18n enabled winGRASS: properties dialog not opening
- #904
- WinGrass: include patched msys.bat in the WinGrass-Installer
- #905
- WinGrass: include patched msys.bat in the WinGrass-Installer
