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

Jochen Krüger kruegerj at gmx.de
Sun Jul 25 19:59:32 EDT 2004


Hello,

I'm trying to use the gdal libraries with MinGW (Dev-C++) - but even 
after checking the respective threads in this newsgroup I can't get it 
to work. This is most likely rooted in my lack of experience with C/C++ 
and/or the compilation and installation of libraries. I'm not a 
professional programmer, just someone in need of a specific tool, with 
no budget but enough enthusiasm to try it myself - so please bare with 
me if the following seems trivial to you:

I need a working GCC library with HDF4 support for a tool essential for 
one of my projects. I tried to use the binary that came with OpenEV and 
also the one available from the gdal website, but with both I get the 
following errors when compiling my programme:

  "[Linker error] undefined reference to `GDALAllRegister'"
  "[Linker error] undefined reference to `GDALOpen'"

Similar error messages are given for any instance where I use one of the 
libraries instructions. I have configured the paths to the includes and 
the library in Dev-C++ correctly, so I must assume that it's something 
with the library I'm using or with the way I'm using it...

I tried to google for some answers, but all I could come up was to use 
extern "C" {} around the include for gdal - but that didn't resolve it. 
Neither did some hints about the absolute path work, as the library is 
not in a seperate path of its own but directly in the compilers lib 
folder. Others mentioned possible problems if the library was compiled 
with a different version of the compiler (the MinGW version I'm using is 
GCC 3.2). In that case I'm damned, as I already tried to compile the 
library and failed completely - even with all the hints available in 
this newsgroup. :(

Here's a part of my code, maybe one of you spots the problem, so I can 
get this running:

-cut-
#include <iostream>
#include <stdlib.h>
#include <gdal_priv.h>

using namespace std;
...
GDALDataset *panDataset;
...
int main(int argc, char *argv[])
{
...
   GDALAllRegister();
   const char* pan_infile=argv[1];
   // Open Pan
   panDataset = (GDALDataset *) GDALOpen( pan_infile, GA_ReadOnly );
   if( panDataset == NULL ) {
     cout << endl << "Pan-Input kann nicht geoeffnet werden!" << endl;
     errorvalue=2;
...
-cut-



More information about the Gdal-dev mailing list