[[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'''. Some hints for building a 64bit winGrass are [http://gvsigce.sourceforge.net/wiki/index.php/Setting_up_the_GNU_Compiler_Collection#Windows here]. === 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 (for dependencies, this is a binary but we'll compile from source later). 6. Also select: * Commandline_Utilities * '''gpsbabel''' * Libs: * '''fftw-devel''' * '''freetype-devel''' * '''freetype-devel-mingw''' * '''gsl-libs''' * '''gsl-devel''' * '''libpng-devel''' * '''libpng-devel-mingw''' * '''libtiff-devel''' * '''libxdr''' * '''libxml2''' * '''pdcurses-devel''' * '''tcltk-devel''' * '''zlib-devel''' 7. Optionally select also GDAL plugins for common GIS formats * Libs: * '''gdal-ecw''' * '''gdal-mrsid''' 8. Click `Next`, the selected packages and their required subpackages will be downloaded and installed automatically. 9. Optionally uninstall '''grass''' package === 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 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 * ''Note'': to change background/foreground color or font size edit `C:\osgeo4w\apps\msys\msys.bat` 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/mingw/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. Download the latest '''make''' program compliant with the OSGeo4W framework from [http://downloads.sourceforge.net/mingw/make-3.81-MSYS-1.0.11-2.tar.bz2 here] (''future updates may be found [https://sourceforge.net/project/showfiles.php?group_id=2435 here]'') 8. Unpack to `c:\osgeo4w\apps\msys` (the content of the sub-folders in the zip-files - ''bin'', ''share'' have to be copied into the related sub-folders of `c:\osgeo4w\apps\msys`) 9. Close and re-open msys to reload the settings. === Pre-built Binaries === Download: (''updates may be found [https://sourceforge.net/project/showfiles.php?group_id=23617 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 to `c:\osgeo4w\apps\msys` (the content of the sub-folders in the zip-files - ''bin'', ''share'' have to be copied into the related sub-folders of `c:\osgeo4w\apps\msys`) == Compiling and Installing GRASS (6.4.x) == 1. Download the latest weekly snapshot GRASS 6.4.x source code from [http://grass.osgeo.org/grass64/source/snapshot/ here] (for latest SVN version, see [wiki:CompileOnWindows#Grass-6.4.svnreleasebranch_64 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.x}}} === 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/bin/grass64 }}} Or to use the new wxpython GUI: {{{ /osgeo4w/bin/grass64 -wxpython }}} == Compiling and Installing Development Versions of GRASS == === Optional Installation of Subversion === The GRASS source tree is stored in an [http://svn.osgeo.org/grass 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 [wiki:HowToSVN here]. A) Command line based: 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 subversion installer and install it to a path without spaces such as {{{c:/Subversion}}} 3. 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 [http://tortoisesvn.tigris.org/ here]. === GRASS 6.4.svn (releasebranch_64) === 1. Download the grass-6.4.svn source tree with: * Subversion (also see [wiki:DownloadSource#GRASS6.4 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 [http://grass.osgeo.org/grass64/source/snapshot/ here] and unpack to `/osgeo4w/usr/src` 2. See [wiki:CompileOnWindows#CompilingandInstalling 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 [wiki:DownloadSource#GRASS6.5 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 [http://grass.osgeo.org/grass65/source/snapshot/ here] 2. See [wiki:CompileOnWindows#CompilingandInstalling below] for compilation and installation. 3. After installation, start with: {{{ /osgeo4w/bin/grass65 }}} === 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 cd /osgeo4w/usr/src/grass_trunk }}} OR * Download a weekly snapshot from [http://grass.osgeo.org/grass70/source/snapshot/ here] 2. Open {{{c:\osgeo4w\etc\ini\msys.bat}}} and at line 3 add: {{{ set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python27 }}} 3. See [wiki:CompileOnWindows#CompilingandInstalling below] for compilation and installation. 4. After installation, start with: {{{ /osgeo4w/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 [wiki:CompileOnWindows#InstalltheenvironmentforcompilationMingW 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 [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 [http://wingrass.fsv.cvut.cz daily builds]. === 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 [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. 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 Grass64-Release-Version: set PACKAGE_DIR=.\GRASS-64-Release-Package set GRASS_PREFIX=%OSGEO4W_DIR%\apps\grass\grass-6.4.1 Grass64-Devel-Version: set PACKAGE_DIR=.\GRASS-64-Devel-Package set GRASS_PREFIX=%OSGEO4W_DIR%\apps\grass\grass-6.4.1svn Grass65-Devel-Version: set PACKAGE_DIR=.\GRASS-65-Devel-Package set GRASS_PREFIX=%OSGEO4W_DIR%\apps\grass\grass-6.5.svn Grass70-Devel-Version: set PACKAGE_DIR=.\GRASS-70-Devel-Package set GRASS_PREFIX=%OSGEO4W_DIR%\apps\grass\grass-7.0.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---Package}}}, e.g. {{{c:\temp\GRASS-64-Release-Package}}}. === Install NSIS (2.45) === 1. Download the [http://prdownloads.sourceforge.net/nsis/nsis-2.45-setup.exe NSIS installer] 2. Install to {{{c:\DevTools}}} === Install NSIS: Untgz Plugin (1.0.16) === 1. Download the [http://www.fdos.org/win32/nsis/plugins/untgz.1.0.16.zip 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: {{{ Grass64: !define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass64_release\demolocation" !define MSYS_BATCH "C:\OSGeo4W\usr\src\grass64_release\mswindows\osgeo4w\msys.bat" Grass65: !define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass6_devel\demolocation" !define MSYS_BATCH "C:\OSGeo4W\usr\src\grass6_devel\mswindows\osgeo4w\msys.bat" Grass70: !define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass_trunk\demolocation" !define MSYS_BATCH "C:\OSGeo4W\usr\src\grass_trunk\mswindows\osgeo4w\msys.bat" }}} 2. Define {{{INSTALER_TYPE}}} * GRASS 6.4: valid options - {{{Release}}}, {{{Devel}}} (default: {{{Release}}}) * GRASS 6.5: valid options - {{{Release}}}, {{{Devel}}} (default: {{{Devel}}}) * GRASS 7.0: valid options - {{{Release}}}, {{{Devel}}} (default: {{{Devel}}}) 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 * 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. == 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 == * [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 * [http://cran.r-project.org/doc/manuals/R-admin.html#Building-R-for-64_002dbit-Windows Building R for 64-bit Windows] * [http://www.gaia-gis.it/gaia-sins/mingw64_how_to.html Building SpatiaLite for 64-bit Windows] * Besides Cygwin and MinGW there is another along similar lines called "som" or "gow" or something? == Errata == * see also [http://trac.osgeo.org/osgeo4w/wiki/pkg-grass#Errata 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. * 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. * The wxGUI vector digitizer and 3D visualization tools do not currently compile on Windows due to missing library indexes in the wxPython dependency. === Open Tickets === [[TicketQuery(status=new|assigned|reopened&keywords~=wingrass)]] === Closed Tickets === [[TicketQuery(status=closed&keywords~=wingrass)]]