[Gdal-dev] Re: MinGW & GDAL: "[Linker error] undefined reference..."

Frank Warmerdam warmerdam at pobox.com
Fri May 28 14:50:29 EDT 2004


J.Krueger wrote:
> C:\DOKUME~1\JOCHEN~1.GOG\LOKALE~1\Temp/ccMXbaaa.o(.text+0xe8):test.cpp: 
> undefined reference to `GDALDataset::GetRasterBand(int)'
> C:\DOKUME~1\JOCHEN~1.GOG\LOKALE~1\Temp/ccMXbaaa.o(.text+0xf0):test.cpp: 
> undefined reference to `GDALRasterBand::GetXSize()'
> C:\DOKUME~1\JOCHEN~1.GOG\LOKALE~1\Temp/ccMXbaaa.o(.text+0xff):test.cpp: 
> undefined reference to `GDALDataset::GetRasterBand(int)'
> C:\DOKUME~1\JOCHEN~1.GOG\LOKALE~1\Temp/ccMXbaaa.o(.text+0x107):test.cpp: 
> undefined reference to `GDALRasterBand::GetYSize()'
> 
> Execution terminated
> -cut-
> 
> it's the same problem. I can use the gdal functions to open the 
> datafiles, but as soon as there's any instructions that to query 
> information from inside the dataset I can't link the binary anymore.
> 
> Btw: I'm using gcc (Dev-C++ IDE with MinGW) to compile the file. And I 
> already have the library in the linker's command line (else I'd get the 
> same errors for the
> 

Hi,

I must confess I haven't been following this build issue closely.  However,
there is one major issue.  GCC and GCC derived compilers used radically
different "name munging" rules for C++ methods than MS Visual C++ does.  So,
in general you won't be able to interact with C++ objects from a VC++ built
library from gcc.  However, you should be able to use the GDAL C API as
C function naming is uniform across compilers.

So try implementing your code more along the lines of:

  int evaluate_Inputfiles(char* infile1, char* infile2) {
   GDALAllRegister();
   // Can the files be opened at all?
   int check=0;
   check=evaluate_Inputfile(infile1);
   if (check) return 1;
   check=evaluate_Inputfile(infile2);
   if (check) return 1;
   // Do they have the same size?
   const char* filename1=infile1;
   const char* filename2=infile2;
   GDALDatasetH highresDataset, lowresDataset;

   highresDataset = GDALOpen( filename1, GA_ReadOnly );
   rastersizex = GDALGetRasterXSize( highresDataset );
   rastersizey = GDALGetRasterYSize( highresDataset );
   int xsize1 = rastersizex;
   int ysize1 = rastersizey;
...
   return 0;
}

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list