- Notifications
You must be signed in to change notification settings - Fork345
INSTALL.md
INSTALL.md
Please readall text below.
- PREREQUISITES
- (A) SOURCE CODE DISTRIBUTION
- (B) COMPILATION
- (C) COMPILATION NOTES for 64bit platforms
- (D) INSTALLATION (first time)
- (E) INSTALLATION ON MACOSX
- (F) RUNNING GRASS
- (G) UPDATE OF SOURCE CODE
- (H) COMPILING INDIVIDUAL MODULES - OWN MODULES
- (I) CODE OPTIMIZATION
- (J) DEBUGGING OPTIONS
- (K) SUPPORT
- (L) GRASS GIS PROGRAMMER'S MANUAL
- (M) CONTRIBUTING CODE AND PATCHES
The install order matters. GRASS needs at least two librarieswhich have to be installed before installing/compiling GRASS:For links to the software, seeREQUIREMENTS.md in thisdirectory.
Installation order:
- PROJ
- GDAL/OGR (compiled without GRASS support)
- optionally: databases such as PostgreSQL, MySQL, SQLite
- GRASS GIS
- optionally: GDAL-OGR-GRASS plugin
GRASS source code is currently distributed in 2 forms:
The full source code version contains all the GRASS source coderequired for compilation. It is distributed as one file (*.tar.gz
package) and the version is composed of 3 numbers, e.g. 3.7.0, 3.7.1etc. Seehttps://github.com/OSGeo/grass/releases.
This version of the source code can be acquired either from the GitHubrepository (https://github.com/OSGeo/grass/) or as a auto-generated snapshot(*.tar.gz
package) of the GitHub repository. The snapshot namecontains the date when the snapshot was created (checked out fromthe GitHub repository), e.g.grass-3.7.git_src_snapshot_2022_04_27.tar.gz
fromhttps://grass.osgeo.org/grass-devel/source/snapshot/
IMPORTANT: All Unix based distributions are different.For Solaris, see hints below.
The command,
./configure --help
explains the options used to disable the compilation of non-mandatoryGRASS modules. SeeREQUIREMENTS.md for details on dependencies.Detailed Wiki notes for various operating systems (MS-Windows, GNU/Linuxdistributions, FreeBSD, AIX, etc) are available at:https://grasswiki.osgeo.org/wiki/Compile_and_Install
First step of the compilation (-g
for debugging, or-O2
for optimization):
CFLAGS="-g -Wall" ./configure
Explanation of make targets:
make install - installs the binarymake bindist - make a binary package with install scriptmake srcdist - make a source package for distributionmake srclibsdist - make a source package for library distributionmake libs - make libraries onlymake clean - delete all files created by 'make'make distclean - 'make clean' + delete all files created by './configure'make libsclean - clean libraries compiled by 'make libs'make htmldocs - generate programmer's documentation as HTML filesmake packagehtmldocs - package programmer's documentation in HTMLmake pdfdocs - generate programmer's documentation as PDF files
Next step is the compilation itself:
make
Note for Solaris users (see also Wiki page above):
To configure GRASS correctly on a system which doesn't have a suitableinstall program (AC_PROG_INSTALL
ignores versions which are known tohave problems), you need to ensure that $srcdir is an absolute path,by using e.g.:
`pwd`/configure ...
or:
./configure --srcdir=`pwd` ...
Then proceed as described above.
Note when using a compiler different from "gcc":
By setting environment variables, the compilernames can be defined (C and C++):
CC=cc CPP=cpp ./configure ...
To successfully compile GRASS on 64bit platforms, the requiredFFTW library has to be compiled with-fPIC
flag:
#this applies to FFTW3, not to GRASS GIS:cd fftw-3.3.4/CFLAGS="-fPIC" ./configuremakemake install
After compilation, the resulting code is stored in the directory
./dist.$ARCH/
and the script (grass
) in
./bin.$ARCH/
To run GRASS, simply start
./bin.$ARCH/grass
or run
make installgrass
See theReadMe.rtf
in the./macosx/
folder and the Wiki page above.
Download a sample data package from the GRASS web site, seehttps://grass.osgeo.org/download/sample-data/
Extract the data set and point the "Database" field in theGRASS GIS startup menu to the extracted directory.
Enjoy.
Assuming that you want to update your current installation fromGitHub, you have to perform a few steps. In general:
- update from GitHub
- configure, compile
In detail:
cd /where/your/grass-source-code/lives/git fetch --allgit merge upstream/main./configure ...makemake install
For details, seeGuide to contributing on GitHub.
To compile (self-made) GRASS modules or to compile modified modulesat least the GRASS libraries have to be compiled locally. This isdone by launching:
make libs
Then change into the module's directory and launch the "make"command. The installation can be either done with "make install" fromthe main source code directory or locally with
"INST_NOW=y make"
You may want to define an alias for this:
alias gmake='INST_NOW=y make'
Then simply compile/install the current module with
gmake
Note: If you keep your module source code outside the standard GRASSsource code directory structure, you will have to change the relativepath(s) in theMakefile
to absolute path(s).
If you would like to set compiler optimisations, for a possibly fasterbinary, type (don't enter a ";" anywhere):
CFLAGS=-O ./configure
or,
setenv CFLAGS -O./configure
whichever works on your shell. Use-O2
instead of-O
if your compilersupports this (note:O
is the letter, not zero). Using the "gcc" compiler,you can also specify processor specific flags (examples, please suggestbetter settings to us):
CFLAGS="-mcpu=athlon -O2"# AMD Athlon processor with code optimisationsCFLAGS="-mcpu=pentium"# Intel Pentium processorCFLAGS="-mcpu=pentium4"# Intel Pentium4 processorCFLAGS="-O2 -msse -msse2 -mfpmath=sse\ -minline-all-stringops"# Intel XEON 64bit processorCFLAGS="-mtune=nocona -m64 -minline-all-stringops"# Intel Pentium 64bit processor
Note: As of version 4.3.0, GCC offers the-march=native
switch thatenables CPU auto-detection and automatically selects optimizations supportedby the local machine at GCC runtime including-mtune
.
To find out optionalCFLAGS
for your platform, enter:
gcc -dumpspecs
See also:https://gcc.gnu.org/
A real fast GRASS version (and small binaries) will be created withLDFLAGS
set to "stripping" (but this disables debugging):
CFLAGS="-O2 -mcpu=<cpu_see_above> -Wall" LDFLAGS="-s" ./configure
TheLDFLAGS=""
part must be undefined as-s
will strip the debugginginformation.
Don't use-O
forCFLAGS
if you want to be able to step through functionbodies. When optimisation is enabled, the compiler will re-order statementsand re-arrange expressions, resulting in object code which barely resemblesthe source code.
The-g
and-Wall
compiler flags are often useful for assisting debugging:
CFLAGS="-g -Wall" ./configure
See also the file./doc/debugging.txt
and the Wiki pagehttps://grasswiki.osgeo.org/wiki/GRASS_Debugging
Note that this code is still actively being developed and errors inevitablyturn up. If you find a bug, please report it to the GRASS bug tracking systemso we can fix it. Seehttps://grass.osgeo.org/contribute/
If you are interested in helping to develop GRASS, please join the GRASSdevelopers mailing list. Seehttps://grass.osgeo.org/development/
The Programmer's manualhttps://grass.osgeo.org/programming8/ isgenerated from the source code. This requires the installation ofdoxygen
(http://www.doxygen.nl) and optionally Graphvizdot
(https://graphviz.org/doc/info/command.html).
The main file is:./grasslib.dox
where all sub-documents haveto be linked to.
To locally generate the 'Programmer's Manual', run
make htmldocs
To generate documentation as a single html file(recommended for simple reading)
make htmldocs-single
This process takes some time. The result will be found inthe filelib/html/index.html
.
To generate the 'Programmer's Manual' in PDF format, run
make pdfdocs
Please see
Markus Neteler and the GRASS Development Team