[GRASSLIST:2055] Re: basic prgramming question
Eric G. Miller
egm2 at jps.net
Wed Jul 4 16:31:54 EDT 2001
On Wed, Jul 04, 2001 at 02:49:44PM -0500, Robert Najlis wrote:
> I am trying to learn how to program GRASS. I have been looking at the
> tutorial and I am just trying to make sure my system is set uo, etc.
> At this point I am just trying to get started - try a few commands, things
> like that. Actually, right now I am just trying to compile a program that
> only has the line #include "gis.h" just to make sure everything is working
> It seems that I need to use gmake5 to compile the program. Is this true?
> If so, would someone be kind enough to give me a sample gmake5 Makefile?
> Or any other example of how to compile c code with GRASS commands in it.
# Name of the program...
# Object files (i.e. replace *.c with *.o)
# The compile line. Pretty much always depend on GISLIB
# And any use of GISLIB must also have $(XDRLIB)
$(CC) -o $@ $(OBJS) $(GISLIB) $(XDRLIB)
^ ^ ^ ^ ^-----------------^ (libgis, libnsl, libz)
\ \ \ \------------- (object files)
(tab) compiler \ alias for $(PGM)
It's very similar to any other Makefile, but actually quite simplified.
The gmake5 program fills in the details.
int main (int argc, char **argv)
gisbase = G_getenv ("GISBASE");
fprintf (stdout, "GRASS programs live under \"%s\"\n", gisbase);
Note: gmake5 won't be built unless you've built GRASS from sources and
installed it. Kinda goofy like that...
Eric G. Miller <egm2 at jps.net>
More information about the grass-user