[gdal-dev] NPE in OGREnvelope constructor when loading GDAL dlls

Tim Azzopardi tim.azzopardi at gmail.com
Tue Feb 18 07:58:35 PST 2020


I'm getting started with GDAL.

I've had success running GDAL code in a windows 32 bit console
app running in Visual Studio 2017 on Windows 10 64 bit using these files
and directories:
    \release-1911-gdal-3-0-2-mapserver-7-4-2-libs\lib\gdal_i.lib (for
linking my code)
    \release-1911-gdal-3-0-2-mapserver-7-4-2-libs\include (for compiling my
code)
    \release-1911-gdal-3-0-2-mapserver-7-4-2\bin (for DLLs required at
runtime)
which I got from
http://download.gisinternals.com/query.html?content=filelist&file=release-1911-gdal-3-0-2-mapserver-7-4-2.zip


I can successfully load a wkt projection file from the console using this
code without any problems
    OGRSpatialReference oSRS;
    oSRS.importFromWkt(&pszWkt_tmp);
    oSRS.dumpReadable();


Now I'm trying to integrate this very simple code into my own 32 bit DLL
which is loaded dynamically by an "off-the-shelf" 32 bit app.

I've written many of these dynamically loaded DLLs before, but when I try
to integrate GDAL into my new DLL, I get an exception when the GDAL DLLs
are being loaded __before_it_ever_gets_to_my_code_. Its stopping seemingly
while loading the GDAL dlls.

The exception occurs (according to the Visual Studio 2017 debugger -
"Exception thrown: write access violation. *this* was nullptr") before
entry into the OGREnvelope constructor at line 60 in ogr_core.h. There is
no call stack shown unfortunately so I've got no idea where the
initialization call is coming from.

class CPL_DLL OGREnvelope
{
  public:
        OGREnvelope() : MinX(std::numeric_limits<double>::infinity()),
    <--  "Exception thrown: write access violation. *this* was nullptr"
                        MaxX(-std::numeric_limits<double>::infinity()),
                        MinY(std::numeric_limits<double>::infinity()),
                        MaxY(-std::numeric_limits<double>::infinity())
        {
        }

I've tried setting the environment variables
   GDAL_DATA=D:\release-1911-gdal-2-4-3-mapserver-7-4-2\bin\gdal-data
   PROJ_LIB=D:\release-1911-gdal-2-4-3-mapserver-7-4-2\bin\proj6\share
but this does not seem to change anything

I appreciate that I am running in a bit of a "niche" environment (32 bit
windows DLL dynamically loaded by a 3rd party app) but if anybody has any
suggestions as to what I might try to make this work I would be very
grateful!

Thanks


-- 
-o-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200218/a7944a1b/attachment.html>


More information about the gdal-dev mailing list