[Gdal-dev] Reading/Writing via GDAL library
Mateusz Loskot
mateusz at loskot.net
Fri Apr 20 16:45:20 EDT 2007
t chheng wrote:
> 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?
I've never used MinGW to build GDAL but I suppose the library specifier
for GDAL is incorrect, may be MinGW needs some special form of -lgdal if
you want to link with import library for DLL, may be -llibgdal...
Check what binaries you have got after you GDAL building.
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Gdal-dev
mailing list