[GRASS-dev] Building a new module for GRASS6.2.3

roberto caselli roberto.caselli at yahoo.it
Fri Mar 28 16:34:31 EDT 2008

These are the first lines of r.example main.c (that I renamed in main.cc)

#include <stdio.h>    
#include <stdlib.h>
#include <string.h>

extern "C"
 #include <grass/gis.h>
 #include <grass/glocale.h>

extern CELL f_c(CELL);
extern FCELL f_f(FCELL);
extern DCELL f_d(DCELL);

And this is its makefile I edit as you told me to do:

PGM = r.example

MOD_OBJS := $(subst .cc,.o,$(wildcard *.cc))     
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd
Then I typed make and here the message:

make: *** No rule to make target `OBJ.i686-pc-linux-gnu/main.o', needed by `/home/roberto/grass/grass-6.2.3/dist.i686-pc-linux-gnu/bin/r.example'.  Stop.
roberto a roberto-laptop:~/grass/grass-6.2.3/raster/r.example$ 

Glynn Clements <glynn a gclements.plus.com> ha scritto: 
roberto caselli wrote:

> Thank you very much! How can I edit the raster example to have a c++ source code (.cc extension)?
> I should edit something in the makefile, but I don't how to do. Someone could help me?

Add the following line before including the *.make files (e.g. Module.make):

 MOD_OBJS := $(subst .cc,.o,$(wildcard *.cc))

By default, MOD_OBJS is determined based upon the .c files in the

Rules.make already includes pattern rules for compiling .cc and .cpp

Note that the GRASS headers don't make allowances for use in C++ code,
so you need to use e.g.:

 extern "C" {

At some point, we should probably change Rules.make to automatically
deal with C++ files (.cc and .cpp extensions; maybe .cxx as well).

Glynn Clements 

Scopri il  Blog di Yahoo! Mail: trucchi, novità, consigli... e la tua opinione!
-------------- parte successiva --------------
Un allegato HTML ? stato rimosso...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20080328/d449bc82/attachment.html

More information about the grass-dev mailing list