Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Hi a while ago I drafted a semi-universal guide on how to compile GRASS GIS on Ubuntu.

Because I had enough emails asking more details I thought to post it here for everyone and if possible to evolve it as we go!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

First and foremost you need to aquire youself a copy of the source-code. To do this first you need to install svn which is a  is a software versioning and revision control system.

Basicaly it downloads the code for you in a designated folder. An in case you find a bug or if you have developed a new feature you can use the same system to create a patch so it would be assimilated in the main source.

To install svn:

$ sudo apt-get install svn

after a successful installation run

$  svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release

So now that you have the source code you need to compile it, To compile grass (or any other software for a matter of fact), you must first meet the prerequisites. Those usually include libraries which provide secondary functions of some-kinds for the main program.

So naturally as a program grows in complexity so does the number of the libraries it depends upon, but those dependencies rarely change very drastically over time. Usually a couple of new libraries for every major release.

Since you're in a debian-based distribution system (ubuntu), we can take advance the fact that it has an older version of GRASS in its repositories and the awesome versatility of apt commands. Taking in mind that we can one-shot the installation of the majority of the required libraries :

$ sudo apt-get update
$ sudo apt-get build-dep grass

The above commands will install all dependencies the package grass needs to compile/run the old version ubuntu has in its repositories. Subsequent Grass releases share 95% of the same libraries. So now we need only to hunt down the remaining 5%.

After you've installed the dependencies change directory of the folder with the source code.

From there run the configure script which produces a file with all the variables that they will be used in the compilation phase.

Most of time you just dry run ./configure, but for grass case the recommended way is to run the ./configure via a basic script file which you will create. For the sake of the example lets call it grass-install.sh and from there we are going to call the ./configure script

$ cd <folders where grass src code residents>
$ touch grass-install.sh
$ chmod +x grass-install.sh

Open grass-install.sh with your favorite text editor (gedit/ nano) and copy/paste this [1]:

CFLAGS="-g -Wall" ./configure \
       --with-cxx --with-freetype=yes \
       --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
       --with-readline --with-python=yes

The above is just an example to get you started. You can change the variables to pretty much what you want depending on your needs. Save it and run it. (From terminal you just type ./grass-install.sh )

The script will NOT complete successfully since most likely will encounter a tcl.h error. this means that the ./configure script can not find the tcl header files, because either its not where the script expects it to be or because you don't have it installed.

Since most likely you will encounter the same errors for others files, i'll describe a semi-universal way locating  the libraries you need:

Say the script can't find tcl.h , so you must install the package which contains it. One way is to google the name of the package which contains is, find the corresponding name of that package and then apt-get it. The smart way tho is to make the apt-get do the searching for you:

$ sudo apt-get install apt-file
$ sudo apt-file update
$ apt-file search <name-of-file>

and for this example

$ apt-file search tcl.h

which is the commands which you ask apt to answer you for all the packages which contain the tcl.h. Normally you want the package which ends in -dev:

$ apt-file search tcl.h | grep -dev

$ sudo apt-get install tcl8.5-dev

after the installation of the package , don't forget to run

$ sudo updatedb

which refreshes the file database.

Afterwards, find where the file tcl.h lingers:

locate tcl.h

which in my case is:  /usr/include/tcl8.5/tcl.h.

Open again grass-install.sh you created before and add at the end the following

--with-tcltk-includes="/usr/include/tcl8.5"

Note: The parameter --with-tcltk-includes= and many other parametres can be found by running ./configure --help from the grass source code directory.

Because it has many options I recommend using grep to locate the info you need

$ ./configure --help | grep tcltk

Re-run the script and it should complete the tcl check successfully, only to hinder in another error. Re-run the above patern (check error, identirfy missing header, locate it, install it, tell the script where it is ) for any other errors and , adjust your configuration script accordingly until it completes successfully.

After ./configure ends successfully you can start the compilation proccess by

$ make
$ make install

(I recommend installing grass in userland  (check the --prefix argument in ./configure --help for more informations).

share|improve this answer
    
for grass7.0 see here - rashadkm.wordpress.com/2012/12/01/… –  rashad Dec 27 '12 at 22:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.