[Gdal-dev] Reading/Writing via GDAL library

Ari Jolma ari.jolma at tkk.fi
Sat Apr 21 04:28:19 EDT 2007


t chheng kirjoitti:
> Hi,
> I'm trying to read/write to vector shapefiles using the GDAL/OGR library.
> I have compiled gdal-1.4.0 and have gdal14.dll
>
> Now I'm trying to use the example code from the tutorial to get the sample
> read/write of vector files working.
> http://www.gdal.org/ogr/ogr_apitut.html
>
> My sample code is basically
> #include <ogrsf_frmts.h>
> int main(int argc, char* argv[])
> {
>                 readShapeFile();
> return 0;
> }
> where readShapeFile is the code provided from the tutorial.
>
> When I compile(note that the dll location is specified
> -L/c/ossimcvs/gdal-1.4.0/lib -lgdal, i also tried -lgdal14), i get an
> undefined reference error.
>
> C:\msys\1.0\bin\make all
> if [ ! -d /.shared_obj ] ; then mkdir /.shared_obj ; fi
> g++ -mthreads -Wall -pipe  -O2 -g3  -L/c/Imaging/OpenCV/lib -lcxcore -lcv
> -lhighgui -lcvaux -L/c/ossimcvs/bin -lossimcontrib_plugin -L/c/ossimcvs/bin
> -lossimopencv_plugin -L/c/ossimcvs/gdal-1.4.0/lib -lgdal  ship_detect.o
> -L/c/ossimcvs/ossim/lib/ossim -lossim          
> -L/c/ossimcvs/libgeotiff-1.2.3/lib -L/c/ossimcvs/tiff-3.8.2/lib -lgeotiff
> -ltiff  -L/c/ossimcvs/jpeg-6b -ljpeg -lm  -ljpeg -o ship_detect.exe
> Info: resolving ossimProjection::RTTI_obj       by linking to
> __imp___ZN15ossimProjection8RTTI_objE (auto-import)
> Info: resolving vtable for ossimStdOutProgressby linking to
> __imp___ZTV19ossimStdOutProgress (auto-import)
> ship_detect.o: In function
> `ZNSt6vectorI7BlobBoxSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_':C:/ossimcvs/ossimConsole/ship_detect.cpp:(.text+0xe):
> undefined reference to `OGRRegisterAll'
> :C:/ossimcvs/ossimConsole/ship_detect.cpp:(.text+0x22): undefined reference
> to `OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**)'
>
> Any ideas why it isn't finding the correct references?
>   

Why do you need to link in the ossim stuff anyway (the undefined 
reference is from ossim)? Are your ossim binaries working?

Ari

> Thanks
>
>
>   


-- 
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka
Geoinformation and positioning technology
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the Gdal-dev mailing list