Posted by: carlosgrohmann | June 7, 2012

Installing GRASS Add-Ons on Mac OSX

After some searching and asking on the GRASS mailing list, I found a good way to install the GRASS add-ons on my OSX Lion.

On William Kyngesburye’s page, we find this note:

Addon Modules

Included is a build template similar to the GEM system for modules. But it doesn’t require the module source to be configured for GEM (I haven’t seen any that are yet). It’s a bit rough. See the included readme for details.

But there’s not much more. There is a nice topic in the french forumSIG, but you need to be registered in order to see the pictures. So I decided to post the instructions here.

First you need to install XCode from the AppleStore and the CLI (command line interface) tools. (the CLI tools can be installed from XCode preferences).

Next, fix the SDKs path: findo the, right-click over it and choose Show package contents. Now go to and copy MacOSX10.7.sdk to /Developer/SDKs (you might need to create this folder).

Then, download and install KyngChaos’ package. It will create a directory for your GRASS version under /Library. Since the directory is read-only, we need to copy the modbuild sub-directory to another place.

In my case, I copied it to


Now we put the directory of the module we want to compile under the module subdir of our new modbuild directory (I’m using here).

Open the Terminal and go to the module’s directory, in my case /Users/guano/Documents/installs/grass/modbuild/module/, and run this (it’s a single line command):

make GRASS_HOME=’/Users/guano/Documents/installs/grass/modbuild/module/’ GRASS_APP=’/Applications/’

just make sure that GRASS_HOME points to your module’s directory (you can drag the folder from Finder in the Terminal and it will give you the full path to it).

After the compilation ends, you should have a directory named dist.i386-apple-darwin10.7.0 under your module’s directory (if you are on Lion. If you run an older version of OSX, the “10.X” part will reflect your system’s version).

Now you just copy the relevant files to /Library/GRASS/6.4/Modules/: copy the executable under bin to /Library/GRASS/6.4/Modules/bin and the files under html to /Library/GRASS/6.4/Modules/doc/html.

Now you should be able to run the add-on via the GRASS terminal:

Nice, huh?



  1. Nice indeed. However I am getting trouble compiling because it complains on some dependencies while compiling your very same module. The error is the following:

    ld: warning: directory not found for option ‘-L/Users/Shared/unix/pgsql-pq-snow/usr/local/pgsql-9.1/lib’
    ld: duplicate symbol _main in OBJ.i386-apple-darwin11.3.0/prueba.o and OBJ.i386-apple-darwin11.3.0/main.o for architecture i386
    collect2: ld returned 1 exit status
    ld: warning: directory not found for option ‘-L/Users/Shared/unix/pgsql-pq-snow/usr/local/pgsql-9.1/lib’
    ld: duplicate symbol _main in OBJ.i386-apple-darwin11.3.0/prueba.o and OBJ.i386-apple-darwin11.3.0/main.o for architecture x86_64
    collect2: ld returned 1 exit status

    Have you had this problem also? Any idea on how to overcome it?

    Thank you a lot for your post

    • Hi there.

      It seems your errors are related to PostgreSQL (the ‘pgsql’ part). Try installing it and see if it works. I can’t really tell from experience, since I installed all GRASS dependencies via macports (I also run GRASS’ development version).
      According to PostgreSQL’s page, the OSX package contains the C libraries, so it should be what you need.

      hope that helps!

  2. Caro professor Carlos, faz apenas alguns dias que eu comprei meu MacBook. Gostaria de saber como é o procedimento para baixar as dependências através do MacPorts (é similar ao home brew?), você teria algum passo a passo referente ao GRASS para isso? outra dúvida, caso haja algum problema na instalação, como eu verifico? estou habituado a compilar o GRASS no Ubuntu, mas no Mountain Lion eu estou completamente perdido! (e quase jogando ele no chão, rs). Um abraço e parabéns pelo seu excelente Post!

    • Caro Marcello,

      O Mac Ports é bem legal e cuida de todas as dependências pra você. Um simples sudo port install grass dever ser suficiente. Quando eu compilei o GRASS 7 no meu Mac, o processo de instalar as dependências foi um pouco manual. Eu rodava meu ./configure e a cada erro, instalava a dependência até não ter mais erros. Ultimamente tenho preferido usar o pacote pronto do William Kyngesburye. Ele tem pacotes do GRASS 6.4, QGIS 1.8 e das dependências (GDAL, FreeType etc). Funciona perfeitamente.


  3. Thanks so much for putting this together. I can’t tell you how much time I wasted before finding this. Thank you!!!

    I made the following makefile to make it easy to copy the executable and HTML into the correct place (see the “deploy” target):

    MODULE_TOPDIR = ../..

    PGM = r.findtheriver


    include $(MODULE_TOPDIR)/include/Make/Module.make

    default: cmd

    cp dist.*/bin/$(PGM) /Library/GRASS/$(GRASS_VERSION_STR)/Modules/bin
    cp dist.*/docs/html/* /Library/GRASS/$(GRASS_VERSION_STR)/Modules/docs/html

  4. Hi Carlos,
    Thank you for posting this. I have a quick question: I have been trying to install* add ons on GRASS 6.4.3 and 6.5 (running Mac OS 10.8). It seems that g.extension and other methods fail because my add-on-path does not exist (?). I never tried add ons before! When I type GRASS_ADDON_PATH to GRASS command line it returns “no such file or directory” error.

    I assume that I need to create an addon (or, modules?) folder and then point the g.extension to that folder by giving the path (?). How can I do this? I thought your post above was answering that and I started following it until you started giving “make GRASS_HOME” commands: it did not work for me!

    Thank you for your time!


%d bloggers like this: