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

Frank Warmerdam warmerdam at pobox.com
Fri May 28 18:42:25 EDT 2004


J.Krueger wrote:
> That would mean if I actually succeeded in building my own c++ gdal 
> library with gcc I could use it, right? Or is that a code issue? If that 
> would work I'd be happy if someone could provide me with his working 
> library (if possible with support for the ERDAS .img format), as I tried 
> my luck with the library already - without success (most likely due to 
> my lack of experience).

J.

That is dcorrect.  If you built the library using MingW it would be linkage
compatible.  Of course, building something as complicated as GDAL for an
environment that is not directly supported can be a daunting task.

>> 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;
>> }
> 
> 
> Mhh... the only change I see is that you're using 'GDALDatasetH' now 
> instead of GDALDataset. Is that all I'd have to change? As I said in my 
> first post - I'm a mere beginner as far as C/C++ is concerned. Basically 
> I'm using my need for the tool I work on as a motivation to learn C++, 
> so some stupid questions are to be expected... ;)

Well, now instead of calling GetRasterXSize() (or GetXSize()?) on the
GDALDataset object, I am now calling GDALGetRasterXSize() and passing in
the GDALDatasetH.  Basically, there are C API functions corresponding to
most C++ methods.  Use it that way and you will be OK.   Though of course,
you won't learn so much about C++.

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