[Gdal-dev] how to link gdal to my programs?

Pushkar Pradhan pushkar at GRI.MsState.Edu
Tue Jan 13 17:19:48 EST 2004


I'm having a little trouble linking gdal libs. to my C++ code.
These are the compile errors:
Redstone[1234] pushkar$ g++ -g -o main
dwt-serial.cpp -Ierrs/ -Imisc/ -Iip/ -I../gdal-1.1.9/include/
dwt-serial.cpp: In function `int main(int, char **)':
dwt-serial.cpp:20: `GDALDataset' undeclared (first use this function)
dwt-serial.cpp:20: (Each undeclared identifier is reported only once
dwt-serial.cpp:20: for each function it appears in.)
dwt-serial.cpp:20: `poDataset' undeclared (first use this function)
dwt-serial.cpp:26: parse error before `)'

I tried -lgdal.1.1, -lgdal.1.1.9 but neither worked. I've set the path to
GDAL (/rstc/user1/erc/pushkar/gdal-1.1.9/lib) in my $LD_LIBRARY_PATH

Here's my first code:
#include <gdal.h>
<--other includes-->
int main(int argc, char **argv)
{
  char *inFile;
  char *dwtFile;

  GDALDataset *poDataset;

  GDALAllRegister();

  inFile = argv[1];

  poDataset = (GDALDataset *) GDALOpen(inFile, GA_ReadOnly);
  if(poDataset == NULL)
    exit(EXIT_FAILURE);
}

Sorry if it was on the gdal homepage and I missed it. Can somebody help.
Thanks
Pushkar




More information about the Gdal-dev mailing list