<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I’m upgrading from GDAL 1.11.0 to 2.0.2 and having difficulties with the new geopackage implementation. When our code attempts to create a new geopackage the driver fails to initialize spatialite. We’ve using the same libspatialite-4.2.0 DLL built with sqlite-amalgamation-3.8.8.2 we used with the previous GDAL build. I haven’t found any relevant differences in how we’re building our GDAL DLL this time.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The failure occurs when sqliteGlobalConfig.mutex.xMutexEnter() is called from sqlite3_mutex_enter() in sqlite3.c. This results in attempting to execute NULL, so it appears sqliteGlobalConfig is not being initialized correctly or being overwritten after initialization. I’ve tried to step through that initialization but it’s just too much code for me to understand in a reasonable period of time.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The originating call in our code is:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   GDALAllRegister();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   _driver = (</span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>GeoPackageDriverPtr</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>)GetGDALDriverManager()->GetDriverByName(</span><span style='font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white'>"GPKG"</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>if</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'> (_driver == </span><span style='font-size:9.5pt;font-family:Consolas;color:#6F008A;background:white;mso-highlight:white'>NULL</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>      </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>throw</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'> </span><span style='font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white'>"Unable to initialize GeoPackageWriter driver."</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   </span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>GDALDriver</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>* gdalDriver = (</span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>GDALDriver</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>*)_driver;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>char</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>** metadata = gdalDriver->GetMetadata();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>if</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'> (!CSLFetchBoolean(metadata, </span><span style='font-size:9.5pt;font-family:Consolas;color:#6F008A;background:white;mso-highlight:white'>GDAL_DCAP_CREATE</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>, </span><span style='font-size:9.5pt;font-family:Consolas;color:#6F008A;background:white;mso-highlight:white'>FALSE</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>))<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>      </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>throw</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'> </span><span style='font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white'>"GPKG driver does not support Create"</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>   _dataset = (</span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>GeoPackageDatasetPtr</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) gdalDriver->Create(_tempFile->path().ascii(),<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>                                                        0,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>                                                        0,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>                                                        0,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>                                                        </span><span style='font-size:9.5pt;font-family:Consolas;color:darkslategray;background:white;mso-highlight:white'>GDT_Unknown</span><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>                                                        0);<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>We’re expecting the call to create the path in _tempFile as a vector-capable geopackage.<o:p></o:p></p><p class=MsoNormal>The call stack from there is:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>sqlite3_mutex_enter()<o:p></o:p></p><p class=MsoNormal>sqlite_create_function_v2()<o:p></o:p></p><p class=MsoNormal>sqlite_create_function()<o:p></o:p></p><p class=MsoNormal>register_spatialite_sql_functions()<o:p></o:p></p><p class=MsoNormal>spatialite_init_ex()<o:p></o:p></p><p class=MsoNormal>OGRSQLiteBaseDataSource::InitNewSpatialite()<o:p></o:p></p><p class=MsoNormal>GDALGeoPackageDataset::OpenOrCreateDB()<o:p></o:p></p><p class=MsoNormal>GDALGeoPackageDataset::Create()<o:p></o:p></p><p class=MsoNormal>OGRGeoPackageDriverCreate()<o:p></o:p></p><p class=MsoNormal>GDALDriver::Create()<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Does anyone have any ideas on what could be wrong?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:10.5pt;color:black'>Alan Stewart<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;color:black'>Senior Software Engineer<o:p></o:p></span></p><p class=MsoNormal><b><span style='color:#C00000'>Terra</span></b><b><span style='color:#E36C0A'>Go </span></b><b><span style='color:#C00000'>Technologies</span></b><span style='font-family:"Times New Roman","serif";color:black'><o:p></o:p></span></p><p class=MsoNormal><span style='color:black'>3200 Windy Hill Road, Suite 1550W</span><span style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span style='color:black'>Atlanta, GA 30339 USA<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'>O.  +1 678.391.9615<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p><p class=MsoNormal><a href="applewebdata://B24C0762-C7C9-4431-8518-ACC915448B89/www.terragotech.com"><span style='color:purple'>www.terragotech.com</span></a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>