![]() |
GRASS Windows Native Binary Building Guide |
| Edited by: Marco Pasetti |
| Last Update: 14 July 2008 |
![]() |
The instructions in this guide are outdated.
The revised and updated version of the guide is available at http://trac.osgeo.org/grass/wiki/CompileOnWindows |
Table of Contents
![]() |
Important Note | ![]() |
Beginners Note |
![]() |
Download | ![]() |
Developers Note |
This document is a basic guide to a Windows Native Binary building of GRASS. It is mainly based on the following articles:
It summarises all the documents above in a brand new "all in one" guide, written specially for beginners.
Any library or application used in this guide is intended as the latest stable release available. Otherwise, developers notes will be added, explaining why I decided to not use the latest stable release.
![]() |
In order to avoid mistakes or misunderstandings, I suggest to read each paragraph entirely before to perform any action. It's very important to follow each step and command explained exactly in the same order as they are written in the guide. |
![]() |
The following instruction have been succesfully tested on both Windwows XP and Windows Vista operative systems. |
![]() |
Download the MSYS installer |
Install to c:\msys
At the command prompt question for post install, type n and then enter.
![]() |
CRTL+V keyboard shortcut. |
Download the MSYS coreutils package (required by some GRASS modules and scripts):
![]() |
Download the MSYS coreutils package |
Unpack it to a temporary folder, then copy all the content of the coreutils-5.97 folder to c:\msys
(overwrite the existing files when asked)
![]() |
Download the MinGW installer |
Select "Download and Install Current Version";
Install only "g++ compiler" and "MinGW Make";
Install to c:\msys\mingw
![]() |
Download the Flex prebuilt binaries package |
Unpack to c:\msys\local
![]() |
The latest release of Flex is (2.5.34), but it has not still ported to Windows. |
![]() |
Download the following archives:
|
Unpack all to c:\msys\local (overwrite the existing files when asked)
![]() |
The latest release of Bison is (2.3), but it has not still ported to Windows. |
![]() |
Download the Zlib source code |
Unpack to c:\msys\local\src
Open c:\msys\local\src\zlib-1.2.3\win32\Makefile.gcc
Replace line 102 with:
INCLUDE_PATH=/usr/local/include
LIBRARY_PATH=/usr/local/lib
SHARED_LIBRARY_PATH=/usr/local/bin
At lines 109-110 delete:
-@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH)
-@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH)
After line 111 add:
-$(INSTALL) $(SHAREDLIB) $(SHARED_LIBRARY_PATH)
After line 118 add:
-$(RM) $(SHARED_LIBRARY_PATH)/$(SHAREDLIB)
Open MSYS console (double click on MSYS icon on your desktop) and type:
cd /usr/local/src/zlib-1.2.3
make -f win32/Makefile.gcc
make install -f win32/Makefile.gcc
![]() |
For unknown reasons, zlib1.dll information label displays that it is 1.2.2.0 version,
while actually it is 1.2.3. |
![]() |
Download the Libpng source code |
Unpack to c:\msys\local\src
Open c:\msys\local\src\libpng-1.2.29\scripts\makefile.mingw
After line 40 add:
prefix=/usr/local
At lines 52-53 edit:
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
In MSYS console, type:
cd /usr/local/src/libpng-1.2.29
cp scripts/makefile.mingw ./Makefile
make
Because make install procedure fails, we need to install it manually:
mkdir /usr/local/lib/pkgconfig
mkdir /usr/local/man/man3
mkdir /usr/local/man/man5
install -m 644 libpng.a /usr/local/lib
install -m 644 libpng.dll.a /usr/local/lib
install -s -m 755 libpng12.dll /usr/local/bin
install -m 644 libpng.pc /usr/local/lib/pkgconfig
install -m 644 png.h pngconf.h /usr/local/include
install -m 644 libpngpf.3 libpng.3 /usr/local/man/man3
install -m 644 png.5 /usr/local/man/man5
cp libpng-config /usr/local/bin
chmod 755 /usr/local/bin/libpng-config
![]() |
An easy way to do that is to copy the previous code and and paste it in a new document; name it install-libpng.sh
and save it into Libpng source code directory; then go to MSYS console and type: install-libpng.sh
|
![]() |
Download the Libjpeg source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/jpeg-6b
./configure --prefix=/usr/local --enable-shared
make
mkdir /usr/local/man/man1
make install
Because make procedure doesn't create the shared library (even if enabled by configure), we need to build it manually:
COMOBJECTS="jcomapi.o jutils.o jerror.o jmemmgr.o jmemnobs.o"
CLIBOBJECTS="jcapimin.o jcapistd.o jctrans.o jcparam.o \
jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o \
jcprepct.o jccoefct.o jccolor.o jcsample.o jchuff.o \
jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o jfdctint.o"
DLIBOBJECTS="jdapimin.o jdapistd.o jdtrans.o jdatasrc.o \
jdmaster.o jdinput.o jdmarker.o jdhuff.o jdphuff.o \
jdmainct.o jdcoefct.o jdpostct.o jddctmgr.o \
jidctfst.o jidctflt.o jidctint.o jidctred.o \
jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o"
LIBOBJECTS="$CLIBOBJECTS $DLIBOBJECTS $COMOBJECTS"
COBJECTS="cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o cdjpeg.o"
DOBJECTS="djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o cdjpeg.o"
TROBJECTS="jpegtran.o rdswitch.o cdjpeg.o transupp.o"
for i in *.exe ; do rm /usr/local/bin/$i ; done
rm *.exe
cd .libs
rm libjpeg.a
rm /usr/local/lib/libjpeg.a
cd ..
gcc -shared -s -o ./.libs/libjpeg.dll -lm -Wl,--out-implib,./.libs/libjpeg.a $LIBOBJECTS
gcc -s -g -O2 -o cjpeg.exe $COBJECTS -L./.libs/ -ljpeg
gcc -s -g -O2 -o djpeg.exe $DOBJECTS -L./.libs/ -ljpeg
gcc -s -g -O2 -o jpegtran.exe $TROBJECTS -L./.libs/ -ljpeg
gcc -s -g -O2 -o rdjpgcom.exe rdjpgcom.o -L./.libs/ -ljpeg
gcc -s -g -O2 -o wrjpgcom.exe wrjpgcom.o -L./.libs/ -ljpeg
cd .libs
install libjpeg.a /usr/local/lib
install libjpeg.dll /usr/local/bin
cd ..
for i in *.exe ; do install $i /usr/local/bin ; done
![]() |
Referring to the MinGW and GCC Documetation (Compiling and Building with MinGW and GCC Command Options - Options for Linking), I guess that the right procedure to build shared libraries (and executables that use them) with MinGW/MSYS should be as follows: First of all we need to delete the static import library built by the standard make procedure, and then all the executables built linking against the static libraries. After that, we will build a shared library with the related import static one, and then all the needed executables, that will be linked against the new shared library. |
![]() |
Download the Libtiff source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/tiff-3.8.2
./configure --prefix=/usr/local \
--with-zlib-lib-dir=/usr/local/lib \
--with-zlib-include-dir=/usr/local/include \
--with-jpeg-lib-dir=/usr/local/bin \
--with-jpeg-include-dir=/usr/local/include
Libtiff should be thus configured as follows:
Libtiff is now configured for i686-pc-mingw32
Installation directory: /usr/local
Documentation directory: ${prefix}/share/doc/tiff-3.8.2
C compiler: gcc -g -O2 -Wall -W
C++ compiler: g++ -g -O2
Enable runtime linker paths: no
Support Microsoft Document Imaging: yes
Support for internal codecs:
CCITT Group 3 & 4 algorithms: yes
Macintosh PackBits algorithm: yes
LZW algorithm: yes
ThunderScan 4-bit RLE algorithm: yes
NeXT 2-bit RLE algorithm: yes
LogLuv high dynamic range encoding: yes
Support for external codecs:
ZLIB support: yes
Pixar log-format algorithm: yes
JPEG support: yes
Old JPEG support: no
C++ support: yes
OpenGL support: no
Now build Libtiff:
make
make install
![]() |
Download the Xdr source code (special stripped-down version with networking code removed) |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/xdr-4.0-mingw2
./configure --prefix=/usr/local --build=i686-pc-mingw32
make
make install
![]() |
Must compile this only as a static library, because of obscure problems with GRASS using shared one! |
![]() |
Download the Freetype source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/freetype-2.3.5
./configure --prefix=/usr/local
make
make install
To complete the installation type:
cd /usr/local/include
mkdir freetype
mkdir ./freetype/config
cd ./freetype2/freetype/config
mv * /usr/local/include/freetype/config
cd ..
rmdir config
mv * /usr/local/include/freetype
cd ..
rmdir freetype
cd ..
rmdir freetype2
Open c:\msys\local\lib\pkgconfig\freetype2.pc
At line 11 replace:
Cflags: -I${includedir}/freetype2 -I${includedir}
with:
Cflags: -I${includedir}
![]() |
Download the FFTW source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/fftw-3.1.2
./configure --prefix=/usr/local \
--disable-fortran \
--with-our-malloc16 \
--enable-shared \
--disable-static \
--enable-threads \
--with-combined-threads \
--enable-portable-binary \
--enable-sse2
make
make install
![]() |
Download the PDCurses source code |
Unpack to c:\msys\local\src
Open c:\msys\local\src\PDCurses-3.3\win32\mingwin32.mak
At line 80 replace:
-copy pdcurses.a panel.a
with:
-cp pdcurses.a panel.a
In MSYS console, type:
cd /usr/local/src/PDCurses-3.3
cd win32
make -f mingwin32.mak DLL=Y all
cp pdcurses.a libcurses.a
install libcurses.a /usr/local/lib
install pdcurses.dll /usr/local/bin
cd ..
install -m 644 curses.h /usr/local/include
![]() |
Download the PROJ.4 source code |
Unpack to c:\msys\local\src
![]() |
Download the US, Canadian and New Zealand datum shift grids |
Unpack to c:\msys\local\src\proj-4.6.0\nad
In MSYS console, type:
cd /usr/local/src/proj-4.6.0
./configure --prefix=/usr/local --enable-shared --disable-static
make
make install
Because make procedure doesn't create shared library (even if enabled by configure), we need to build it manually:
cd src
for i in *.exe ; do rm /usr/local/bin/$i ; done
rm /usr/local/bin/invgeod.exe
rm /usr/local/bin/invproj.exe
rm *.exe
cd .libs
rm libproj.a
rm /usr/local/lib/libproj.a
gcc -shared -s -o libproj.dll -lm -Wl,--out-implib,libproj.a *.o
cd ..
gcc -s -g -O2 -o cs2cs.exe cs2cs.o gen_cheb.o p_series.o .libs/emess.o -L./.libs/ -lproj
gcc -s -g -O2 -o geod.exe geod.o geod_set.o geod_for.o geod_inv.o .libs/emess.o -L./.libs/ -lproj
gcc -s -g -O2 -o nad2bin.exe nad2bin.o -L./.libs/ -lproj
gcc -s -g -O2 -o nad2nad.exe nad2nad.o .libs/emess.o -L./.libs/ -lproj
gcc -s -g -O2 -o proj.exe proj.o gen_cheb.o p_series.o .libs/emess.o -L./.libs/ -lproj
cp proj.exe invproj.exe
cp geod.exe invgeod.exe
cd .libs
install libproj.a /usr/local/lib
install libproj.dll /usr/local/bin
cd ..
for i in *.exe ; do install $i /usr/local/bin ; done
![]() |
This is an optional dependency, needed only if you want to build both Quantum GIS and GRASS. |
![]() |
Download the GEOS source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/geos-3.0.0
./configure --prefix=/usr/local
make
make install
![]() |
This is an optional dependency, needed only if you want to build both Quantum GIS and GRASS. |
![]() |
Download the GSL source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/gsl-1.11
./configure --prefix=/usr/local
make
make install
![]() |
This is an optional dependency, needed only if you want to build both Quantum GIS and GRASS. |
![]() |
Download the Expat source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/expat-2.0.1
./configure --prefix=/usr/local
make
make install
![]() |
Download the PostgreSQL source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/postgresql-8.3.1
./configure --prefix=/usr/local/pgsql \
--with-includes=/usr/local/include \
--with-libraries=/usr/local/lib \
--without-readline
make
make install
![]() |
Even if a prebuilt PostgreSQL Windows binary package is available, it generates problems with GDAL building. This because the Windows release of PostgreSQL is built using Visual Studio, while MinGW (and specially GDAL built with MinGW) has problems linking against VS built libraries. |
![]() |
Download the SQLite source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/sqlite-amalgamation-3.5.9
./configure --prefix=/usr/local/sqlite
make
make install
![]() |
Download the GDAL source code |
Unpack to c:\msys\local\src
Open c:\msys\local\src\gdal-1.5.2\configure
At line 23832 replace:
expat_lib_flags="-L$expat_prefix/lib -lexpat"
with:
LIBS="$LIBS -L$expat_prefix/lib -lexpat"
In MSYS console, type:
cd /usr/local/src/gdal-1.5.2
./configure --prefix=/usr/local \
--without-grass \
--with-sqlite3=/usr/local/sqlite \
--with-pg=/usr/local/pgsql/bin/pg_config.exe
When finished, you should have the following screen output:
GDAL is now configured for i686-pc-mingw32
Installation directory: /usr/local
C compiler: gcc -g -O2
C++ compiler: g++ -g -O2
LIBTOOL support: yes
LIBZ support: internal
GRASS support: no
CFITSIO support: no
PCRaster support: internal
NetCDF support: no
LIBPNG support: internal
LIBTIFF support: internal (BigTIFF=yes)
LIBGEOTIFF support: internal
LIBJPEG support: internal
LIBGIF support: internal
OGDI support: no
HDF4 support: no
HDF5 support: no
Kakadu support: no
JasPer support: no
ECW support: no
MrSID support: no
GRIB support: no
cURL support (wms/wcs/...): no
PostgreSQL support: yes
MySQL support: no
Xerces-C support: no
Expat support: yes
ODBC support: no
PGeo support: no
OCI support: no
SDE support: no
DODS support: no
SQLite support: yes
DWGdirect support no
PANORAMA GIS support: no
INFORMIX DataBlade support: no
GEOS support: yes
Old-gen python no
SWIG Bindings: no
Statically link PROJ.4: no
enable OGR building: yes
enable pthread support: no
hide internal symbols: no
Open c:\msys\local\src\gdal-1.5.2\GNUmakefile
After line 4 add:
GDAL_ROOT=.
Finally build and install GDAL:
make
make install
![]() |
|
![]() |
Download the AVCE00 source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/avce00-2.0.0
make
install avcexport.exe /usr/local/bin
install avcimport.exe /usr/local/bin
![]() |
Download the E00compr source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/e00compr-1.0.0
make
install e00conv.exe /usr/local/bin
![]() |
Download the Python installer |
Install to C:\DevTools\Python
Add C:\DevTools\Python to your PATH system variable.
![]() |
Download the Python Extensions installer |
Just launch the installer, it will automatically set the correct install path.
![]() |
Download the wxPython installer (Win32 Unicode) |
Install to C:\DevTools\Python\Lib\site-packages
![]() |
Download the Tcl source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/tcl8.5.2/win
./configure --prefix=/usr/local/tcl-tk --enable-shared
make
make install
cd /usr/local/tcl-tk/bin
mv tclsh85.exe tclsh.exe
![]() |
Download the Tk source code |
Unpack to c:\msys\local\src
In MSYS console, type:
cd /usr/local/src/tk8.5.2/win
./configure --prefix=/usr/local/tcl-tk --with-tcl=/usr/local/src/tcl8.5.2/win --enable-shared
make
make install
cd /usr/local/tcl-tk/bin
mv wish85.exe wish.exe
![]() |
Download the GRASS source code |
Unpack to c:\msys\local\src
Open c:\msys\local\src\grass-6.3.0\man\Makefile
At line 13, replace:
default: $(MANPAGES)
with:
default:
In MSYS console, type:
cd /usr/local/src/grass-6.3.0
./configure \
--prefix=/usr/local \
--with-includes=/usr/local/include \
--with-libs=/usr/local/lib \
--disable-x11 \
--without-x \
--with-cxx \
--enable-shared \
--enable-largefile \
--with-opengl=windows \
--with-fftw \
--with-freetype \
--with-proj-share=/usr/local/share/proj \
--with-gdal=/usr/local/bin/gdal-config \
--with-tcltk --with-tcltk-includes=/usr/local/tcl-tk/include --with-tcltk-libs=/usr/local/tcl-tk/bin \
--with-sqlite --with-sqlite-includes=/usr/local/sqlite/include --with-sqlite-libs=/usr/local/sqlite/lib \
--with-postgres --with-postgres-includes=/usr/local/pgsql/include --with-postgres-libs=/usr/local/pgsql/lib
When finished, you should have the following screen output:
GRASS is now configured for: i686-pc-mingw32
Source directory: /usr/local/src/grass-6.3.0
Build directory: /usr/local/src/grass-6.3.0
Installation directory: ${prefix}/grass-6.3.0
Startup script in directory: ${exec_prefix}/bin
C compiler: gcc -g -O2
C++ compiler: c++ -g -O2
Building shared libraries: yes
64bit support: no
OpenGL platform: Windows
NVIZ: yes
BLAS support: no
C++ support: yes
DWG support: no
FFMPEG support: no
FFTW support: yes
FreeType support: yes
GDAL support: yes
GLw support: no
JPEG support: yes
LAPACK support: no
Large File Support (LFS): yes
Motif support: no
MySQL support: no
NLS support: no
ODBC support: no
OGR support: yes
OpenGL support: yes
PNG support: yes
PostgreSQL support: yes
Python support: no
Readline support: no
SQLite support: yes
Tcl/Tk support: yes
wxWidgets support: no
TIFF support: yes
X11 support: no
MacOSX application: no
Having GRASS successfully configured, now you can build it:
export PATH="/usr/local/bin:/usr/local/tcl-tk/bin:/usr/local/sqlite/bin:/usr/local/pgsql/lib:$PATH"
make
When finished, you should have the following compilation log:
GRASS GIS compilation log
-------------------------
Started compilation: Mon Jun 16 09:08:19 GMT 2008
--
Errors in:
/usr/local/src/grass-6.3.0/raster/r.li/r.li.daemon
/usr/local/src/grass-6.3.0/raster/r.li/r.li.edgedensity
/usr/local/src/grass-6.3.0/raster/r.li/r.li.patchdensity
/usr/local/src/grass-6.3.0/raster/r.li/r.li.patchnum
/usr/local/src/grass-6.3.0/raster/r.li/r.li.shape
/usr/local/src/grass-6.3.0/raster/r.li/r.li.simpson
/usr/local/src/grass-6.3.0/raster/r.li/r.li.shannon
/usr/local/src/grass-6.3.0/raster/r.li/r.li.mps
/usr/local/src/grass-6.3.0/raster/r.li/r.li.mpa
/usr/local/src/grass-6.3.0/raster/r.li/r.li.padcv
/usr/local/src/grass-6.3.0/raster/r.li/r.li.padsd
/usr/local/src/grass-6.3.0/raster/r.li/r.li.padrange
/usr/local/src/grass-6.3.0/raster/r.li/r.li.cwed
/usr/local/src/grass-6.3.0/raster/r.li/r.li.richness
/usr/local/src/grass-6.3.0/raster/r.li/r.li.dominance
--
In case of errors please change into the directory with error and run 'make'.
If you get multiple errors, you need to deal with them in the order they
appear in the error log. If you get an error building a library, you will
also get errors from anything which uses the library.
--
Finished compilation: Mon Jun 16 10:11:17 GMT 2008
make: *** [default] Error 1
![]() |
The best way to check it, is to open c:\msys\local\src\grass-6.3.0\error.log using your favourite web client.
|
Then install GRASS:
make install
Now GRASS should be installed in c:\msys\local\grass-6.3.0
The last thing you have to do, before to launch and test your GRASS build, is
to set some environmental variables in grass63.bat and grass63 files.
Copy the following code and and paste it in a new document,
then save it as c:\msys\local\bin\grass63.bat (overwrite the existing file):
@echo off
rem #########################################################################
rem #
rem # GRASS Initialization
rem #
rem #########################################################################
rem *******Environment variables***********
rem Directory where your .grassrc6 file will be stored
set HOME=%USERPROFILE%
rem Name of the wish (Tk) executable
set GRASS_WISH=wish.exe
rem Path to the shell command
set GRASS_SH=c:\msys\bin\sh.exe
rem Set Path to utilities (libraries and bynaries) used by GRASS
set PATH=c:\msys\bin;c:\msys\local\bin;c:\msys\local\tcl-tk\bin;%PATH%
set PATH=c:\msys\local\pgsql\lib;c:\msys\local\sqlite\bin;c:\msys\local\gpsbabel;%PATH%
rem Set Path to MSIE web browser
set GRASS_HTML_BROWSER=%PROGRAMFILES%/Internet Explorer/iexplore.exe
rem Path to the proj files (notably the epsg projection list)
set GRASS_PROJSHARE=c:\msys\local\share\proj
set WINGISBASE=c:\msys\local\grass-6.3.0
"%WINGISBASE%\etc\init.bat" %*
Copy the following code and and paste it in a new document,
then save it as c:\msys\local\bin\grass63 (overwrite the existing file):
#! /bin/sh
#############################################################################
#
# $Id: grass.src 22360 2007-01-22 22:41:45Z markus $
#
# MODULE: GRASS Initialization
# AUTHOR(S): Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
# PURPOSE: The source file for this shell script is in
# lib/init/grass.src and is the grass startup script. It
# requires a source file because the definition of GISBASE
# is not known until compile time and is substituted from the
# Makefile. Any command line options are passed to Init.sh.
# COPYRIGHT: (C) 2000-2005 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################
trap "echo 'User break!' ; exit" 2 3 9 15
# Set the GISBASE variable
GISBASE=/usr/local/grass-6.3.0
export GISBASE
# Set the PATH variable
PATH="/usr/local/tcl-tk/bin:/usr/local/sqlite/bin:/usr/local/pgsql/lib:/usr/local/gpsbabel:$PATH"
export PATH
exec "$GISBASE/etc/Init.sh" "$@"
Now you have two main options to run GRASS: launch the grass63.bat file in c:\msys\local\bin, or
open a MSYS console, type grass63 and then enter.
Finally, if you want to test the new wxPython GUI, open a MSYS console, type grass63 -wxpython and then enter.