[GRASS5] Almost there...

Okay, I think I'm almost there...

I'm stuck on the following error (ignorance is such a drag and I've been
scouring the Gmakefile trying to get this resolved to no avail since there
doesn't seem to be a consistent way to generate a Gmakefile.

$ gmake5 -i src.contrib/OSU/v.example
  SRC = /cygdrive/n/grass.src/grass5.0.1/src
  CMD = /cygdrive/n/grass.src/grass5.0.1/src/CMD
  UNUSED = /cygdrive/n/grass.src/grass5.0.1/unused
  HEADER = head.i686-pc-cygwin
  ARCH = i686-pc-cygwin
  GISBASE = /cygdrive/n/grass.src/grass5.0.1/dist.i686-pc-cygwin
  VERSION = 5.0.1 January 2003
#################################################################
/cygdrive/n/grass.src/grass5.0.1/src.contrib/OSU/v.example
  make -f OBJ.i686-pc-cygwin/make.rules

gcc -O -o v.example OBJ.i686-pc-cygwin/main.o OBJ.i686-pc-cygwin/interface.o
OBJ.i686-pc-cygwin/open_vect_in.o OBJ.i686-pc-cygwin/op
en_vect_out.o
OBJ.i686-pc-cygwin/process.o -lgis -lvect -ldig2 -ldig_atts -lgis
-lvect -ldig2 -ldig_atts
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/bin/ld:
cannot find -lgis
collect2: ld returned 1 exit status
make: *** [v.example] Error 1

Here's the Gmakefile I've "stolen" from the web as well
(http://www.geog.le.ac.uk/jwo/teaching/c_prog/14vector/index.html)

##############################################################
## A Gmakefile - This is necessary for all GRASS programs ##
## and links all necessary functions and ##
## libraries. ##
##############################################################

PROG = v.example
#-----------^ Name of the GRASS module here.

LIBES = $(GISLIB) $(VASK) $(MATHLIB) $(VECTLIB) $(DIG_ATTLIB)
#-----------^ Library necessary for all GRASS programs.
#---------------------^ Parses keyboard input.
#------------------------------^ For non arithmetic maths.
#-----------------------------------------^ For any vector manipulation.
#----------------------------------------------------^ Vector attributes.

INCLUDES =\
  example.h
#-----------------^ Any include files go here.

COMPILE_FLAGS = -O
#---------------^ For optimising the code.

EXTRA_CFLAGS = $(VECT_INCLUDE)
#-------------------^ This call if vectors are ever used.

OBJ =\
main.o \
interface.o \
open_vect_in.o \
open_vect_out.o \
process.o
#----------^ These are the names of all seperate files that
# the programmer creates. Must have ONE tab in
# front of each line.

######### DEPENDENCIES #########

$(PROG): ${OBJ} ${LIBES}
  ${CC} $(COMPILE_FLAGS) -o $@ ${OBJ} ${LIBES} ${LIBES}

#
#-----^ This compiles the whole program bringing all labels together.

$(OBJ): ${INCLUDES}

$(LIBES): #
#---^ Ignore this line (used for future additions of the library).

When I run "$ gmake5 -i src.contrib/OSU/v.example" that's what I get....

I'm so close I can taste it, now...

Jeff.

Jeff D. Hamann wrote:

I'm stuck on the following error (ignorance is such a drag and I've been
scouring the Gmakefile trying to get this resolved to no avail since there
doesn't seem to be a consistent way to generate a Gmakefile.

gcc -O -o v.example OBJ.i686-pc-cygwin/main.o OBJ.i686-pc-cygwin/interface.o
OBJ.i686-pc-cygwin/open_vect_in.o OBJ.i686-pc-cygwin/open_vect_out.o
OBJ.i686-pc-cygwin/process.o -lgis -lvect -ldig2 -ldig_atts -lgis
-lvect -ldig2 -ldig_atts
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/bin/ld:
cannot find -lgis

There should be some -L switches there; at least one for the directory
containing the GRASS libraries.

Here's the Gmakefile I've "stolen" from the web as well
(http://www.geog.le.ac.uk/jwo/teaching/c_prog/14vector/index.html)

It appears to be somewhat out of date.

LIBES = $(GISLIB) $(VASK) $(MATHLIB) $(VECTLIB) $(DIG_ATTLIB)

1. You don't need $(VASK) unless you're actually using that
functionality.

2. You probably do need $(XDRLIB).

COMPILE_FLAGS = -O

Don't set this variable. If you really need any extra compile flags,
set EXTRA_CFLAGS instead.

$(PROG): ${OBJ} ${LIBES}
  ${CC} $(COMPILE_FLAGS) -o $@ ${OBJ} ${LIBES} ${LIBES}

1. This is a link command, and should use $(LDFLAGS), not
$(COMPILE_FLAGS), e.g.

$(BIN_CMD)/$(PGM): main.o $(DEPLIBS)
  $(CC) $(LDFLAGS) -o $@ main.o $(LIBES) $(MATHLIB) $(XDRLIB)

2. Don't use $(LIBES) as a dependency; it will typically consist of -l
switches rather than pathnames. Each GRASS library has two variables
e.g. libgis has $(GISLIB) and $(DEPGISLIB); the latter is of a
suitable form for use as a dependency.

The best approach is to start with a Gmakefile from a similar module,
preferably one which uses the same libraries, and ideally one which is
under active development (so that the Gmakefile is more likely to be
up-to-date).

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

On Sat, Feb 01, 2003 at 03:00:05AM +0000, Glynn Clements wrote:
[...]

The best approach is to start with a Gmakefile from a similar module,
preferably one which uses the same libraries, and ideally one which is
under active development (so that the Gmakefile is more likely to be
up-to-date).

If you don't want to download the full source code for that,
you can simply go to the CVS page on the GRASS web site and
use the CVS HTML interface. This enables you to download individual
files from CVS and/or tar balls from (sub)directories.

Markus Neteler

Markus Neteler wrote:

> The best approach is to start with a Gmakefile from a similar module,
> preferably one which uses the same libraries, and ideally one which is
> under active development (so that the Gmakefile is more likely to be
> up-to-date).

If you don't want to download the full source code for that,
you can simply go to the CVS page on the GRASS web site and
use the CVS HTML interface. This enables you to download individual
files from CVS and/or tar balls from (sub)directories.

Anyone wishing to compile their own modules has to have the GRASS
source code. The binary distributions don't contain any libraries
except libgis/libdatetime, or the headers for any other libraries, or
any of the files from src/CMD which are required by the gmake5 build
system.

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