How to: Compile GRASS from source code on a Linux (Fedora Core 4) machine, and have everything work properly when you are done.
Who these instructions are for:
1) Someone at least fairly familiar with Linux and
Unix shell commands.
2) Someone who needs to compile the GRASS 6.1
development version from source code frequently.
3) Someone who has a Linux workstation on which they can experiment.
One important caveat:
These instructions are known to
work on the Fedora Core 4 Linux distro, and for MEPIS debian/ubuntu ONLY (tested on four separate
machines). They may work for other distros, but I can neither confirm
nor deny this. Please use them at your own risk. No
support express or implied is offered, and the consequences of
following these instructions are yours alone. I cannot beheld
responsible for any damages to your workstation incurred during the
install process. That being said, I do believe in open source, so if
you have any problems, e-mail me, and I will offer any advice that I have.
First things first:
You must install all the
necessary libraries and packages prior to installing GRASS. FC4 comes
with the compilation tools (if you chose to install them), and all the
rest are available through the redhat up2date package manager, or from
their respective websites. You must use the Synaptic Package manager
with a MEPIS install (or other debian/ubuntu install) to download ALL
of the required packages (including the compilation tools). To see the
list of required packages, please click here
to go the list provided on the GRASS website. Search your machine for
the required files, and install them if you do not find them. *Note*
I was UNABLE to correctly compile hdf4 support for MEPIS debian/ubuntu.
The only result of this is that I cannot directly import TERRA ASTER
imagery.
Install overview:
*please note that these instructions are based off of instructions by Markus Neteler which are available here.
First, here is an overview of the correct install order (from the Markus Neteler page above):
- PROJ4
- GEOS (optional)
- PostgreSQL, mySQL, sqlite, [unix]ODBC (optional)
- GDAL/OGR without GRASS support
- GRASS (see below)
- new GDAL/OGR-GRASS [1] compiled plugin (optional. NOTE: the GRASS libraries
have to be linked into /usr/[local/]lib/ for this, run 'ldconfig' then)
- QGIS
Install instructions:
Steps 1-3:
Start by installing the above
packages in order until step 4 (GDAL). ( For FC4, you can use the RPM's created
by Markus Neteler and available from his webpage here. For debian/ubuntu, get the packages with aptget or the Synaptic package manager (most will be under "science")).
*IMPORTANT*:
Make
sure that you do not attempt to install GDAL from RPM's (from
Markus' site or any other website) or from the debian or ubuntu
repositories (ie. through the synaptic package manager). If you have
already installed it,
you may need to search for and remove every part of the previous
installation if you run into GDAL problems later.
Step 4:
For both types of linux, you should now go to the GDAL download page: http://www.gdal.org/dl/,
and download the latest source code (will be tarred and zipped as a
".tar.gz", the current version as of this writing is 1.3.1). Unzip it
to a directory that you create and name "GDAL_source_'version'".
Open a (BASH) terminal, become a "super user" (type 'su' and enter the
root password when prompted) and cd to that directory. At the prompt
copy and paste all the following text:
./configure
--without-grass --with-hdf4=/usr/local/hdf4.2r1 --with-libtiff=internal
--with-geotiff=internal --with-python --without-ogdi --without-libgrass
--enable-shared
You may download a text file of this here.
Make sure that the
options "--without-GRASS" and "--without-libgrass" are
there, and also make sure that the option "--with-hdf4='path'" points
to the version of hdf4 that you have installed (for FC4, ours is
hdf4.2r1 that lives in
/usr/local) (remember, I was UNABLE to compile hdf4 on the MEPIS
machine, so if you don't have hdf4, change this to --with-hdf4=no).
Hit enter, and see that text starts to spew forth. Check the last
lines to make sure that there are no error messages. If there are, then most
likely you haven't pathed correctly.
*VERY IMPORTANT*: At
this point, if you have previously installed GDAL (or attempted to install it
with different configuration options), you must type "make clean"
and hit enter. Otherwise, continue to the next step.
When this is done type "make"
and hit enter: more text will spew forth... again, check for error messages.
Now the GDAL source code is compiled into binaries, but is not yet installed.
Now type "make install",
and hit enter. This will put the GDAL binaries you just compiled where they are
supposed to go.
Step 5:
Now we must do the same thing for GRASS. To get the absolute
latest source code you must access the CVS repository via the terminal, and
download them to you computer. The instructions for this are on the
"downloads" page of the GRASS website,
and are very clear, so I will
not repeat them here (scroll down below the GRASS 6.1.x box and read
where it says "Download from CVS". Create a directory named
"GRASS_CVS_source" and download the source codes there. Alternatively,
you can download the "weekly CVS
snapshot" source code ".tar.gz" file in the conventional (ie. click the
link) fashion, and unzip it into this directory.
Either way is fine and the source codes can be updated from the CVS
later.
After you have downloaded the
source files, go back to the terminal (make sure you are still a "super
user") and cd to the directory you just created. As before, copy and
paste all the text below to the command prompt:
./configure --enable-shared --with-fftw
--with-includes=/usr/include --with-libs=/usr/lib --with-motif
--with-freetype=yes --with-freetype-includes=/usr/include/freetype2
--with-nls --with-gdal=/usr/local/bin/gdal-config --with-proj
--with-proj-includes=/usr/include --with-proj-libs=/usr/lib --with-glw
--with-cxx --with-mysql --with-mysql-includes=/usr/include/mysql
--with-mysql-libs=/usr/lib/mysql --with-postgres
--with-postgres-includes=/usr/include/pgsql
--with-postgres-libs=/usr/lib --with-odbc=yes
--with-odbc-includes=/usr/include --with-odbc-libs=/usr/lib
--with-glw=yes --enable-largefile
You can download the above as a text file here.
*IMPORTANT*: Make absolutely sure that all the paths are correct
for your system. They should be fine, but double check this. It will save you
from some potentially very vexing issues later.
Again, type "make"
and hit enter (note this will make text spew forth for several minutes, check
for error messages).
Also run "make clean" just to be sure. Then type
"make install" and let it run.
Now GRASS is installed into the
directory "/usr/local/GRASS-6.1.cvs".
We aren't done yet!: Now, the GRASS libraries
are only in "/usr/local/GRASS-6.1.cvs/lib", but other programs don't know to look for them there. You will now need to create symbolic links to
all the GRASS libraries (anything that starts with "libgrass") in the directories /usr/lib
and usr/local/lib so that other programs (specifically GDAL) can find them. We do that by using the "ln -s /path/file_name
/path/linked_file_name" command. After all the libraries are linked in both /usr/lib and usr/local/lib, type
"ldconfig" at the terminal and press enter to let the system update its library database (a slight
pause after hitting enter lets you know that it is updating).
Step 6:
Now download the
"gdal-grass-1.3.1-2.i386.rpm" file from Markus's website, (if you choose, you may download and compile the source codes from the GDAL downloads page. However, I have not done so and cannot advise about configuration options) and then
the "gdal-grass-debuginfo-1.3.1-2.i386.rpm"
*IMPORTANT*:
You cannot install these RPM's by double clicking on the icon (as you
can with the other RPM's). Instead you must cd into the directory where
you downloaded the rpm's to (make sure you are still a "super user"),
and type "rpm --file='file_name'" (in this case "rpm --file=gdal-grass-1.3.1-2.i386.rpm").
Now hopefully everything will in GRASS will work. Open a terminal and type
"grass61" at the prompt and hit enter. GRASS should start and ask you
for a location and mapset. Hopefully you have either downloaded the Spearfish
example data set from the grass website, or have some GRASS data sets that you have gotten elsewhere. Either way, you should probably put these
datasets somewhere "shared" (like in the /home directory, under a
directory you name "grassdata". Browse to the location, select a
mapset, and start up GRASS...
Now we must test to see whether
the GDAL plugin has installed correctly and that the GRASS--GDAL
connection works properly. Under the "file" menu, select
"import" --> "raster map" --> "multiple formats using
GDAL" and try to import a geotiff (into a new location if
necessary.
you can create one as an option in this module). You can get geotiffs
of the many geospatial websites if you have none... Alternatively you
may choose to "export" --> "raster map" --> "multiple formats
using GDAL" from the "file" menu. Try to export one of the Spearfish
raster maps as a geotiff. If it works without giving you an error
message, then everything
is peachy... If not, try to reinstall the GDAL plugin...
Step 7:
Install QGIS with the QGIS GRASS
plugin if you like (it's very useful for producing publishable quality
maps from GRASS datasets). Download and install the RPM's from Markus Neteler's site or compile from source ( here is the QGIS website: http://qgis.org/ ). RPM's are also available from the QGIS website.
After you install QGIS, restart
GRASS, and at the command prompt (you will be working from WITHIN the
GRASS session) type QGIS and hit enter. After QGIS starts, select the
"plugins" filemenu, and select "plugin manager". Turn all the plugins
on. Now you will be able to open and manipulate GRASS raster and vector
data from within QGIS. The GRASS environment variables are set
automatically in QGIS because you are running it from within an GRASS
session.
Step 8:
Congratualte yourself! This has
been very difficult, and you have persevered! Now you have a fully
working GRASS install which you can update at will from the GRASS CVS
repository. To do so, please refer to the CVS instructions on the GRASS downloads page.
Back to Isaac's GRASS resouces page