[[TOC]] = 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 [http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe 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 [https://sourceforge.net/tracker/?func=detail&atid=102435&aid=1511614&group_id=2435 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 [http://forums.mozillazine.org/viewtopic.php?f=42&t=759325 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: (''[https://sourceforge.net/project/showfiles.php?group_id=2435 updates may be found here]'') * '''Temp bugfix''' (see [http://trac.osgeo.org/osgeo4w/ticket/118 here]), '''msysCORE-1.0.11-bin''' from [http://downloads.sourceforge.net/project/mingw/MSYS%20Base%20System/msys-1.0.11/msysCORE-1.0.11-bin.tar.gz here] * '''bin-utils''' from [http://downloads.sourceforge.net/mingw/binutils-2.19.1-mingw32-bin.tar.gz here] * '''gcc-core''' from [http://downloads.sourceforge.net/mingw/gcc-core-3.4.5-20060117-3.tar.gz here] * '''gcc-g++''' from [http://downloads.sourceforge.net/mingw/gcc-g%2B%2B-3.4.5-20060117-3.tar.gz here] * '''mingw32-make''' from [http://downloads.sourceforge.net/mingw/mingw32-make-3.81-20080326-3.tar.gz here] * '''mingw-runtime''' from [http://downloads.sourceforge.net/mingw/mingwrt-3.15.2-mingw32-dev.tar.gz here] * '''mingw-utils''' from [http://downloads.sourceforge.net/mingw/mingw-utils-0.3.tar.gz here] * '''w32api''' from [http://downloads.sourceforge.net/mingw/w32api-3.13-mingw32-dev.tar.gz here] 7. Unpack all to c:\osgeo4w 8. Download an updated '''make''' from [http://downloads.sourceforge.net/mingw/make-3.81-MSYS-1.0.11-2.tar.bz2 here] (required for grass-7.0.svn) (''[https://sourceforge.net/project/showfiles.php?group_id=2435 updates may be found here]'') 9. Unpack to c:\osgeo4w\apps\msys === Pre-built Binaries === Download: (''[https://sourceforge.net/project/showfiles.php?group_id=23617 updates may be found here]'') * '''bison''' from [http://downloads.sourceforge.net/gnuwin32/bison-2.1-bin.zip here] * '''bison-deps''' from [http://downloads.sourceforge.net/gnuwin32/bison-2.1-dep.zip here] * '''flex''' from [http://downloads.sourceforge.net/gnuwin32/flex-2.5.4a-1-bin.zip here] * '''gettext-bin''' from [http://downloads.sourceforge.net/gnuwin32/gettext-0.14.4-bin.zip here] * '''gettext-lib''' from [http://downloads.sourceforge.net/gnuwin32/gettext-0.14.4-lib.zip here] * '''libiconv-lib''' from [http://downloads.sourceforge.net/gnuwin32/libiconv-1.9.2-1-lib.zip here] * '''libintl-bin''' from [http://downloads.sourceforge.net/gnuwin32/libintl-0.14.4-bin.zip here] * '''libintl-lib''' from [http://downloads.sourceforge.net/gnuwin32/libintl-0.14.4-lib.zip here] * '''regex''' from [http://downloads.sourceforge.net/gnuwin32/regex-2.7-bin.zip here] * '''bc''' from [http://sourceforge.net/projects/gnuwin32/files/bc/1.06-2/bc-1.06-2-bin.zip/download here] * '''readline''' from [http://sourceforge.net/projects/gnuwin32/files/readline/5.0-1/readline-5.0-1-bin.zip/download here] Unpack all to c:\osgeo4w == Compiling and Installing GRASS (6.4.0) == 1. Download the latest GRASS 6.4.0 source code from [http://grass.osgeo.org/grass64/source/snapshot/ here]. 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 simply commands. For more see [http://grass.osgeo.org/wiki/Working_with_SVN Working with SVN]. 1. Download '''Collabnet Subversion Command-Line Client (1.6)''' from [http://www.collab.net/downloads/subversion/ here]. (You'll have to register on Collabnet) 2. Run the installer and install to a path without spaces(?) such as c:/Subversion or c:/Programs/Subversion 3. 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 }}} To: {{{ 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 [http://tortoisesvn.tigris.org/ here]. === Grass-6.5.svn (develbranch_6) === 1. Download the grass-6.5.svn source tree with: * subversion (also see [wiki:DownloadSource#GRASS6.5 here]) {{{ cd /osgeo4w/usr/src svn co https://svn.osgeo.org/grass/grass/branches/develbranch_6/ grass6_devel }}} OR * Download a weekly snapshot from [http://grass.osgeo.org/grass65/source/snapshot/ here] 2. Follow the instructions above for grass-6.4.0, but change all grass64 to grass65 etc. Note also that the line numbers may differ slightly between GRASS 6.4.0svn (releasebranch_6_4) and GRASS-6.5.svn (develbranch_6). To update your source tree later using subversion and recompile type: {{{ cd /osgeo4w/usr/src/grass6_devel make distclean svn up rm mwindows/osgeo4w/configure-stamp ./mswindows/osgeo4w/package.sh }}} === Grass-7.0.svn (trunk) === 1. Download the grass-7.0.svn source tree with: * subversion (also see [wiki:DownloadSource#GRASS7 here]) {{{ cd /osgeo4w/usr/src svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk }}} OR * Download a weekly snapshot from [http://grass.osgeo.org/grass70/source/snapshot/ 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") 2. Open c:\osgeo4w\etc\ini\msys.bat and at line 3 add: {{{ set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python25 }}} 3. Open c:\osgeo4w\usr\src\grass_trunk\mswindows\osgeo4w\package.sh, and make the same changes as in the grass-6.4.0 section above. Note also that the line numbers may differ slightly between GRASS 6.4.0svn (releasebranch_6_4) and GRASS-7.0.svn (trunk). 4. To compile, type in MSYS console: {{{ cd /osgeo4w/usr/src/grass_trunk ./mswindows/osgeo4w/package.sh }}} * If any errors came up during the compile they will be recorded in error.log. If they are non-critical modules you can finish the installation with: {{{ make install }}} 5. You're finished, start with: {{{ /osgeo4w/apps/grass/bin/grass70 }}} To update your source tree later using subversion and recompile type: {{{ cd /osgeo4w/usr/src/grass_trunk 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 (for easy installation on any windows machine) are included in the GRASS source tree at mswindows/README.html. Or, for version 6.4.0svn (releasebranch_6_4) [http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/mswindows/README.html?format=raw click here] == TODO == * QGIS * Add cairo support to grass-7.0.svn * Possibly use these cairo binaries [http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-1.6.4-2.zip deps] and [http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev-1.6.4-2.zip 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 [wiki:CompileOnWindowsMSVC] == See also == * [http://trac.osgeo.org/osgeo4w/wiki/pkg-grass GRASS package page in OSGeo4W] (including [http://trac.osgeo.org/osgeo4w/wiki/pkg-grass#PackagerNotes packaging notes]) * [wiki:BuildingOnWindows 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 [http://trac.osgeo.org/osgeo4w/wiki/pkg-grass#Errata 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. === Open Tickets === [[TicketQuery(status=new|assigned|reopened&keywords~=wingrass)]] === Closed Tickets === [[TicketQuery(status=closed&keywords~=wingrass)]]