[gdal-dev] Mixing gdal and shapelib?

Frank Warmerdam warmerdam at pobox.com
Thu Sep 2 10:21:46 EDT 2010


Stephen Woodbridge wrote:
> Hi devs,
> 
> I have written a program that uses gdal to access raster images and 
> shapelib calls to read and write some shapefiles.
> 
> I'm getting some SEGVs and I crashed valgrind! see valgrind gdb runs below.
> 
> It also appears the gdal/ogr has a copy of shapelib build into it so I 
> have tried loading -lshp -lgdal and -lgdal -lshp, but I'm guess having 
> two copies is bad.
> 
> I know I could use ogr, but I already had the code written with shapelib 
> and I have not used ogr before.

Steve,

As long as GDAL is not configured --with-hide-internal-symbols=yes it
should be possible to link against GDAL and call it's copy of the Shapelib
functions safely and avoid linking in a separate copy.  You might need to
use the include files from gdal/ogr/ogrsf_frmts/shape in this case too.

It is bad karma to have two copies of shapelib in your build.

I would add there is currently no mechanism for GDAL to link against an
external shapelib.  I really never intended for shapelib to be a standalone
library - I always envisaged it being "built in" as it is with GDAL.

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