[GRASS-dev] unknown reference to G__gisinit

Xavier Rubio xrubio at gmail.com
Sat May 5 07:19:53 EDT 2012


Hi, thanks for your answers. Markus, I compared the compilation of
"r.example" with my own system and realized that the only difference was
the compiler (gcc or g++). Compiling my code with gcc worked, so the
problem is the fact that I was developing C++ code to call a C function
(the binary symbols are different, so it explains the errors).
Fix this problem was rather easy; I specified the compiler that the gis.h
include is C code:

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

and it worked, just in case other people finds the same problem.

Thanks!

Xavi

2012/5/5 Markus Neteler <neteler at osgeo.org>

> On Fri, May 4, 2012 at 1:37 PM, Xavier Rubio <xrubio at gmail.com> wrote:
> >
> > Hi, I'm starting to develop some code using Grass following the
> programmer's
> > manual:
> > http://grass.osgeo.org/programming6/gislib.html
> >
> > but I'm unable to link an example with just the library initialization,
> > receiving this error:
> >
> > gcc -o main.o -c -I/usr/lib/grass64/include main.cxx
> > gcc -o test main.o -L/usr/lib/grass64/lib -lgrass_gis
> > main.o: In function `main':
> > main.cxx:(.text+0x3b): undefined reference to `G__gisinit(char const*,
> char
> > const*)'
>
> It is highly recommended to use a GRASS style Makefile. This will likely
> solve the problem. For a simple one, see
>
> http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/general/g.ask/Makefile
>
> for raster or vector processing, respectively
>
> http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/doc/raster/r.example/
>
> http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/doc/vector/v.example/
>
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20120505/de12ac58/attachment.html


More information about the grass-dev mailing list