[gdal-dev] How to use GDAL Library

Ajmeri Iqbal isajmeri at rediffmail.com
Tue Mar 31 02:00:51 EDT 2009


hi,following is my code.;;;;GDALDataset *poDataset;GDALAllRegister();poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );if( poDataset != NULL ){double adfGeoTransform[6];qDebug()<<"Driver: "<<poDataset->GetDriver()->GetDescription()<<poDataset->GetDriver()->GetMetadataItem   ( GDAL_DMD_LONGNAME );// at this point error popupqDebug()<<"Size is "<<poDataset->GetRasterXSize()<<poDataset->GetRasterYSize()<<poDataset->GetRasterCount();if( poDataset->GetProjectionRef() != NULL )qDebug()<<"Projection is `"<<poDataset->GetProjectionRef();if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None ){qDebug()<<"Origin = "<<adfGeoTransform[0]<<adfGeoTransform[3];qDebug()<< "Pixel Size = "<<adfGeoTransform[1]<<adfGeoTransform[5];}};;;;but the problame is resolve.i builded this code with MinGW so as per Jürgen's conversation C++ api won't work from MinGW unlessGDAL is also built with MinGW.now i recoded with C-api and working fine.but now i have confusion about functionality of C-api and C++-api.shell i continue with C-api or build GDAL library with MinGW and use C++-api?On Mon, 30 Mar 2009 15:34:18 +0200 Benoît Andrieu wroteWell... Have you checked your path to your include files ?Could I see the part of the code where the errors occured ? Thx Benoît Andrieubea at ixsea.combenoit.andrieu@gmail.com----- Original Message ----- From: Ajmeri Iqbal To: bea at ixsea.com Cc: gdal-dev at lists.osgeo.org Sent: Monday, March 30, 2009 3:22 PMSubject: Re :Re: Re :Re: Re :Re: [gdal-dev] How to use GDAL LibraryHi,Thanks Benoît Andrieubea for your reply.you are right, there is no need any cpp file. but when i build the same code given in GDAL tutorial with QT Creator popups the following error.g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debugImageRW.exe debug/main.o -L"d:Qt2009.01qtlib" gdal_i.lib -lQtCored4mingw32-make[1]: Leaving directory `D:/QT_Projects/ImageRW'mingw32-make: Leaving directory `D:/QT_Projects/ImageRW'debug/main.o: In function `main':D:/QT_Projects/ImageRW/main.cpp:34:   reference to `GDALDataset::GetRasterCount()'D:/QT_Projects/ImageRW/main.cpp:34:   reference to `GDALDataset::GetRasterYSize()'D:/QT_Projects/ImageRW/main.cpp:34:   reference to `GDALDataset::GetRasterXSize()'collect2: ld returned 1 exit statusmingw32-make[1]: *** [debugImageRW.exe] Error 1mingw32-make: *** [debug] Error 2Exited with code 2.but the same code i builded with VC++ 2005, its working fine.unfortunatly i want to link GDAL library in QT.the bellow is my QT .pro file settingQT -= guiTARGET = ImageRWCONFIG += consoleCONFIG -= app_bundleTEMPLATE = appSOURCES += main.cppLIBS += gdal_i.libthanks in advance.On Mon, 30 Mar 2009 14:42:07 +0200 Benoît Andrieu wroteHi ! You won't need any cpp files.Personally, I am using the FWTools package which bundles dll, libs and headers files. You just have to compile using gdal_priv.hThen link to gdal_i.libThen provide with your runtime all the dlls which gdal_fw.dll is depending to.You will find which dlls it is depending to by using Dependency Walker (http://www.dependencywalker.com/). Then your runtime will be able to use all of the image formats drivers that GDAL was compiled to support. I hope this will help. Regards, Benoît Andrieubea at ixsea.combenoit.andrieu@gmail.com----- Original Message ----- From: Ajmeri Iqbal To: bea at ixsea.com Cc: gdal-dev at lists.osgeo.org Sent: Monday, March 30, 2009 11:06 AMSubject: Re :Re: Re :Re: [gdal-dev] How to use GDAL LibraryHi,Actually i m working on Generic image reading/writing and display on viewer with all of its information, so i think i need all listed library. but dont know how to use them in my code.i have downloded gdal_i.lib, gdal.dll and its include .h files..h files contains only the prototype function to link with library but i could not find its .cpp file which may containt implementation function of that linking function of .h files.can u please give me broad idea or step by step procedure about how do i link these library to c++ code.thanks in advanceRegards,IqbalOn Fri, 27 Mar 2009 18:54:01 +0100 Benoît Andrieu wroteHi, I am using FWTools 2.2.9So I am releasing my softwares with most of the dlls (you can use depends to find which). The linking is done with :gdal_i.libgeos_i.libgeotiff_i.liblibtiff_i.libproj_i.lib But yo may want to use more or less libraries... Regards, Benoît Andrieubea at ixsea.combenoit.andrieu@gmail.com----- Original Message ----- From: Ajmeri Iqbal To: bea at ixsea.com Cc: gdal-dev at lists.osgeo.org Sent: Friday, March 27, 2009 3:11 PMSubject: Re :Re: [gdal-dev] How to use GDAL LibraryHi Benoît Andrieu,Thanks for reply.i already saw that tutorial,but the problame is how to and which library to be linked using QT(most probably same way of C/C++).coz there is a three library named gdal16.dll, gdal_i.lib and gdal.lib.On Fri, 27 Mar 2009 11:33:42 +0100 Benoît Andrieu wroteHi, If you want to use GDAL in C / C++, take a look at the tutorial at http://www.gdal.org/gdal_tutorial.html.It is really straightforward, I used this for the integration of GDAL in our modules and it worked fine. Regards, Benoît Andrieubea at ixsea.combenoit.andrieu@gmail.com----- Original Message ----- From: Ajmeri Iqbal To: gdal-dev at lists.osgeo.org Sent: Friday, March 27, 2009 11:06 AMSubject: [gdal-dev] How to use GDAL LibraryDear all,I want to use GDAL library in my project using QT.How could i use this library for Reading and writing the Raster images (i.e. JPEG,JPEG200,TIFF,GeoTiff,BMP,PNG,GIF, etc)please help me.Thanks in advance_______________________________________________gdal-dev mailing listgdal-dev at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090331/3cca973f/attachment-0001.html


More information about the gdal-dev mailing list