[GRASS5] test module linking problem

manderso at cs.wisc.edu manderso at cs.wisc.edu
Thu Feb 27 14:37:14 EST 2003


Hi --

I've been trying to get just a tiny little baby test grass module to
compile, and I'm running into a linking problem.  I attempted to compile the
program:

  g++ -c -o pointdump.o pointdump.cpp -I/scratch/grass/src/grass5.0.1/src/include

and then to link it:

  g++ -L/scratch/grass/src/grass5.0.1/src/libes/LIB.i686-pc-linux-gnu\
      -L/u/m/a/manderso/grass/lib\
      -L/s/lapack/lib\
      -o pointdump\
      pointdump.o\
      -lvect -ldig2 -lgis -ldig_atts\
      /scratch/grass/src/grass5.0.1/src/libes/vect32/libes/LIB.i686-pc-linux-gnu/libtrans.a\
      -lvask -lncurses -ltermcap -lbsd-compat -lm  -lz
  pointdump.o: In function `main':
  pointdump.o(.text+0x1c): undefined reference to `G_gisinit(char*)'
  pointdump.o(.text+0x21): undefined reference to `G_define_option()'
  pointdump.o(.text+0x86): undefined reference to `G_parser(int, char**)'
  pointdump.o(.text+0xbb): undefined reference to `G_find_vector2(char*, char*)'
  pointdump.o(.text+0xe3): undefined reference to `Vect_open_old(Map_info*, char*, char*)'
  pointdump.o(.text+0xf3): undefined reference to `G_fatal_error(char*, ...)'
  pointdump.o(.text+0xf8): undefined reference to `Vect_new_line_struct()'
  pointdump.o(.text+0x116): undefined reference to `Vect_read_next_line(Map_info*, line_pnts*)'
  pointdump.o(.text+0x1a2): undefined reference to `Vect_destroy_line_struct(line_pnts*)'
  pointdump.o(.text+0x1b0): undefined reference to `Vect_close(Map_info*)'

Initially I had tried to do this in one step, and to only try to link
against -lgis and -lvect, but the linking errors were the same either way.
I got the more elaborate gcc incantation used here by looking at how the
grass build process compiled a vector module (v.transform, specifically).

I used nm to look at the symbols inside of libgis.a and libvect.a, which
live in

  /scratch/grass/src/grass5.0.1/src/libes/LIB.i686-pc-linux-gnu

and the symbols it is complaining about do seem to be there.

The code to pointdump.cpp is very simple (though undebugged, as I haven't
gotten it to link yet)...it is attached below.  Any ideas on why the linking
is failing?

Any help is much appreciated.  Thanks.

//====================================================================================================
#include "gis.h"
#include "Vect.h"

#include <iostream>
using std::cout;
using std::cerr;
using std::endl;

int main(int argc, char *argv[]) {
   struct Map_info Map; /* Map info */ 
   struct line_pnts *Points; /* Poly-Line data */ 
   G_gisinit (argv[0]); /* init GIS lib */ 

   struct Option *input;

   input = G_define_option();
   input->key             = "input";
   input->type            = TYPE_STRING;
   input->required        = YES;
   input->multiple        = NO;
   input->gisprompt       = "old,dig,vector";
   input->description     = "vector input file";

   if (G_parser (argc, argv)) {exit (-1);}

   char *name = input->answer;
   char *mapset;
   mapset = G_find_vector2(name,"");

   if (0 > Vect_open_old (&Map, name, mapset)) { /* open file */ 
      G_fatal_error ("Cannot open vector file");
   }
   Points = Vect_new_line_struct();
   while (0 < Vect_read_next_line (&Map, Points)) {
      cout << "x:" << *(Points->x) << " y:" << *(Points->y) << endl;
   }

   Vect_destroy_line_struct(Points); /* remove allocation */ 
   Vect_close(&Map); /* close up */
} 
//====================================================================================================

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Matt C. Anderson          email: manderso at cs.wisc.edu
	                    web: http://www.cs.wisc.edu/~manderso
-----------------------------------------------------------------
      No thank you Delmar.  A third of a gopher would only
      arouse my appetite without bedding her back down...
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




More information about the grass-dev mailing list