[Gdal-dev] Registering a format driver at run-time

Frank Warmerdam warmerdam at pobox.com
Mon Feb 13 18:04:52 EST 2006


Peng Gao wrote:
> I am trying to figure out a way I can load/register a GDAL driver at
> run-time.
> The way I go about it is as the following, for ECW for example:
> 
> 1) Build/link GDAL13 without ECW;
> 2) Build/link ECW driver, ECW and GDAL import libraries, NCS*.lib, and
> gdal_i.lib into a 
>    separate dll, grf_ecw.dll;
> 3) Build/link my app with gdal_i.lib;
> 4) Load grf_ecw.dll at run-time using LoadLibrary, find register_ECW
> symbol address, and call
>    the function to register ECW with GDAL;
> 
> Are there any issues, technical and otherwise, at all to do this? 
> 
> My prototype mostly works, except I keep hitting unhandled exceptions
> "Unhandled exception at 0x7c901230 in myapp.exe: User breakpoint" 
> whenever a GDAL dataset is released. Can anyone help?
> 
> I am using VC++7 and Windows XP.

Gao,

Your approach is fine.  I believe the problem relates to deleting
something from the wrong heap context, though I am not sure of it at
all.

Could you try commenting out the following two lines?

             if( --poUnderlyingIOStream->nFileViewCount == 0 )
                 delete poUnderlyingIOStream;

This is in ~ECWDataset in gdal/frmts/ecw/ecwdataset.cpp.

By the way, there is another approach to plugins for drivers.
It is described (very briefly) at:

http://www.gdal.org/classGDALDriverManager.html#1e10f0276813a9996f7f7c57486e787b

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