[GRASSLIST:4549] Re: Advice on changing source code for g.region command

Glynn Clements glynn.clements at virgin.net
Fri Sep 20 09:58:11 EDT 2002


Roy Sanderson wrote:

> Many thanks for the advice.  When you suggest that it would be much more
> efficient to use G_get_window() directly to abstract the region
> information, am I right in assuming that you are recommending a programming
> approach similar to that in the r.example code I've just discovered on the
> GRASS website, which I see you've co-authored?

Actually, when I said:

> >It's safe to assume that nothing which is written in C will attempt to
> >parse the output from "g.region -p", as it's vastly simpler to just
> >use G_get_window() directly.

I was referring to programs which are part of GRASS. IOW, changing the
output format of "g.region -p" certainly won't break any part of GRASS
which is written in C. It probably won't break scripts either, but
it's harder to be certain.

> What's confusing me a
> little bit is that when I run gmake5 on the r.example code, it assumes I
> have write access permission to the main grass5 /etc/bin/cmd directory,
> which of course a non-administrator cannot write to.  What should an
> ordinary user do?  Sorry - I guess I'm showing my ignorance here, but this
> approach of interfacing GRASS to user-written C programs is new to me.

"gmake5" won't work in this situation.

You can compile programs which use the GRASS "libgis" library the same
way as for any other program. E.g. for r.example, the following
Makefile should work (change GISBASE according to where GRASS is
installed):

GISBASE=/usr/local/grass5
CFLAGS=-I$(GISBASE)/include
LDFLAGS=-L$(GISBASE)/lib

r.example: main.o
	$(CC) $(LDFLAGS) -o $@ main.o -lgis -ldatetime -lz -lm

main.o: main.c
	$(CC) $(CFLAGS) -c main.c

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-user mailing list