Version 84 (modified by hamish, 13 years ago) ( diff )

no more make error

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.
  1. Run the installer.
  1. Select Advanced Install, and Next.
  1. 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 (?))
  1. Select grass from the desktop section (this is a binary but we'll compile from source later).
  1. 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
  1. 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)
  1. Type:
     mkdir /c/osgeo4w/apps/msys/osgeo4w
  2. Copy c:\osgeo4w\apps\msys\etc\fstab.sample to c:\osgeo4w\apps\msys\etc\fstab (without .sample)
  1. Open c:\osgeo4w\apps\msys\etc\fstab
  1. At line 16, change:
    c:/mingw		/mingw
    c:/ActiveState/perl	/perl


c:/osgeo4w/	/osgeo4w
  1. Download the MinGW packages:

(or newer??)

  1. Unpack all to c:\osgeo4w
  1. Download an updated make from here (required for grass-7.0.svn)

(or newer??)

  1. Unpack to c:\osgeo4w\apps\msys

Pre-built Binaries

Download: (or newer??)

Unpack all to c:\osgeo4w

Compiling and Installing GRASS (6.4.0)

  1. Download the latest GRASS 6.4.0 source code from here.
  1. Unpack to c:\osgeo4w\usr\src
  1. Open c:\osgeo4w\usr\src\grass64\mswindows\osgeo4w\ and at line 12, change:
    --with-libs="/c/OSGeo4W/lib /c/MinGW/lib" \
    --with-includes="/c/OSGeo4W/include /c/MinGW/include" \


--with-libs=/c/OSGeo4W/lib \
--with-includes=/c/OSGeo4W/include \
  1. To compile, type in MSYS console:
    export PATH="/osgeo4w/bin:$PATH"
    cd /osgeo4w/usr/src/grass-6.4xxx (change to dir of the version you downloaded)

When finished, you should have the following compilation log (c:\osgeo4w\usr\src\grass-6.4xxx\error.log):

(UPDATE: Makefile fixed to avoid building if Msys detected)

GRASS GIS compilation log
Started compilation: Mon Feb 16 10:11:17 GMT 2009
Errors in:
make: *** [default] Error 1

Currently* cannot be compiled on Windows, but grass will run fine without them.

  1. Because of these errors in the install script stops. To finish it type:
    make install

Now GRASS should be installed in c:\osgeo4w\apps\grass-6.4.0\


To start grass use the icon on the desktop.

OR, if you want to be able to use the command line from within grass, you'll need a different start-up file.

  1. Open C:\OSGeo4W\apps\grass\bin\grass64 and at line 24 add:

(UPDATE: PYTHONPATH setting bug in now fixed)

if [ -z "$PYTHONPATH" ] ; then
  1. To start grass, type in MSYS console:

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 simply commands. For more see Working with SVN.

  1. Download Collabnet Subversion Command-Line Client (1.6) from here. (You'll have to register on Collabnet)
  1. Run the installer and install to a path without spaces(?) such as c:/Subversion or c:/Programs/Subversion
  1. Open c:\osgeo4w\etc\ini\msys.bat and at line 1 add the path to your subversion folder, eg. change:
    PATH %PATH%;%OSGEO4W_ROOT%\apps\msys\bin


PATH %PATH%;%OSGEO4W_ROOT%\apps\msys\bin;/c/Programs/Subversion

Alternatively TortoiseSVN, a plugin for Windows Explorer, can be used for managing the local source tree. Download here.

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 grass6-devel
      #For Subsequent updates, type:
      cd /osgeo4w/usr/src/grass6-devel
      svn up


  • Download a weekly snapshot from here
  1. Follow the instructions above for grass-6.4.0, but change all grass64 to grass65, etc.

nb. To update your source tree later using subversion and recompile type:

cd /osgeo4w/usr/src/grass6-devel
svn up
rm configure-stamp

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 grass_trunk
      #For Subsequent updates, type:
      cd /osgeo4w/usr/src/grass_trunk
      svn up


  • Download a weekly snapshot from here and unpack to c:\osgeo4w\usr\src (if you use this method in the instructions below change "grass_trunk" to the folder name of your snapshot eg. "grass-7.0.svn_src_snapshot_2009_03_29")
  1. Open c:\osgeo4w\etc\ini\msys.bat and at line 3 add:
    set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python25
  2. Open c:\osgeo4w\usr\src\grass_trunk\lib\python\, and at line 208 change:

(UPDATE: automatic OS detection fixed in SVN; moved to

os.execvp("g.parser", [name] + argv)


os.execvp("g.parser.exe", [name] + argv)
  1. Open c:\osgeo4w\usr\src\grass_trunk\include\Make\Multi.make, at at line 19 change:
    	$(call linker)
    define objs_rule
    $(BIN)/$(1)$(EXE): $$(patsubst %.o,$(OBJDIR)/%.o,$$($$(subst .,_,$(1)_OBJS)))


define objs_rule
$(BIN)/$(1)$(EXE): $$(patsubst %.o,$(OBJDIR)/%.o,$$($$(subst .,_,$(1)_OBJS))) $(DEPENDENCIES)
	$$(call linker)
  1. Download the script from here

(why not use the native grass 7 ver?? grass/trunk/mswindows/osgeo4w/

  1. Put in c:\osgeo4w\usr\src\grass_trunk\mswindows\osgeo4w\ (you may have to create the latter two folders)
  1. Open c:\osgeo4w\usr\src\grass_trunk\mswindows\osgeo4w\, and make the same changes as in the grass-6.4.0 section above
  1. Also, at line 35 change:

(UPDATE: not needed if you pull mswindows\osgeo4w\ from the GRASS 7 source code)



--with-freetype-includes=/osgeo4w/include/freetype2 \
--without-cairo \
  1. To compile, type in MSYS console:
    cd /osgeo4w/usr/src/grass_trunk
  2. Once the script fails on the* errors (see above), type:

(UPDATED: fixed to avoid building if Msys detected)

make install
  1. Once this is finished open c:\osgeo4w\apps\grass\grass-7.0.svn\etc\, and at line 150 change:

(still aplicable???)



  1. Open c:\osgeo4w\apps\grass\bin\grass70, and at line 25 add:

(still needed???)

if [ -z "$PYTHONPATH" ] ; then
  1. You're finished, start with:

nb. To update your source tree later using subversion and recompile type:

cd /osgeo4w/usr/src/grass_trunk
make distclean
svn up
rm configure-stamp


Here are a few common problems and their solutions:

With module...If you get the errorDo the following
r.mapcalc, r.univar, or raster3d/baseNo rule to make target ... needed by 'progs'Update msys's make (see step 8 in the MinGW section above)
scripts/*ImportError: No module named grassFix PYTHONPATH to *nix-style (eg. PYTHONPATH=/osego4w/apps/Python25)


  • QGIS
  • Add cairo support to grass-7.0.svn
    • Possibly use these cairo binaries deps and bin. (check for newer versions)
    • Preferably get cairo added to osgeo4w tree.
  • Add geos support for grass-7.0.svn (need geos-config file)

Building with MS Visual Studio

See also

Note: See TracWiki for help on using the wiki.