<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Could not load Spatialite extension in QT5.9]]></title><description><![CDATA[<p dir="auto">Hi, I am trying to load Spatialite as extension in Qt, I have done that before with Qt4.8, but I failed with the QT5.9.<br />
I changed the sqlite.pri by removing "SQLITE_OMIT_LOAD_EXTENSION", and I did some change on the sqlite.c by removing the "#define SQLITE_OMIT_LOAD_EXTENSION 1", and adding "#define SQLITE_ENABLE_LOAD_EXTENSION 1".<br />
I also add the following lines to openDatabase(....):<br />
#if defined(SQLITE_ENABLE_LOAD_EXTENSION)<br />
| SQLITE_LoadExtension|SQLITE_LoadExtFunc<br />
#endif</p>
<p dir="auto">Now the "requet.setQuery("SELECT load_extension('spatialite')", dbProject);" function is recognized, but I got this message:<br />
error "The specified procedure could not be found.\r\nUnable to fetch row"<br />
If I take a look on my debug output in MSVC14, I can see that the spatialite.dll and all its dependencies are loaded.</p>
<p dir="auto">Notice: I tested this with my Spatialite and also the mod_spatialite that I download form their website.</p>
<p dir="auto">Any ideas about this problem?<br />
Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/79923/could-not-load-spatialite-extension-in-qt5-9</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 17:16:21 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/79923.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Jun 2017 11:21:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Could not load Spatialite extension in QT5.9 on Wed, 14 Jun 2017 12:04:03 GMT]]></title><description><![CDATA[<p dir="auto">hey <a class="plugin-mentions-user plugin-mentions-a" href="/user/mca4213">@<bdi>MCA4213</bdi></a> , thanks!! I'm pretty sure that I set all the corresponding flags but I will check again.</p>
]]></description><link>https://forum.qt.io/post/399467</link><guid isPermaLink="true">https://forum.qt.io/post/399467</guid><dc:creator><![CDATA[Ferni]]></dc:creator><pubDate>Wed, 14 Jun 2017 12:04:03 GMT</pubDate></item><item><title><![CDATA[Reply to Could not load Spatialite extension in QT5.9 on Sat, 10 Jun 2017 20:47:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ferni">@<bdi>Ferni</bdi></a> , I don't have experiance on android, but :<br />
did you make the changes on the sqlite3 file ( in my case sqlite3.c)?   by removing the omit definition and altering the enable extension by:" | SQLITE_LoadExtFunc" (change the existing one)?<br />
The not authorized error is generated when the omit definition is enabled, or the  SQLITE_LoadExtFunc has not been added.<br />
you can find some other details on my discussion on the stackoverflow: [<a href="https://stackoverflow.com/questions/44427868/could-not-load-spatialite-extension-in-qsqlite-qt-5-9" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/44427868/could-not-load-spatialite-extension-in-qsqlite-qt-5-9</a>](link url)</p>
]]></description><link>https://forum.qt.io/post/398700</link><guid isPermaLink="true">https://forum.qt.io/post/398700</guid><dc:creator><![CDATA[MCA4213]]></dc:creator><pubDate>Sat, 10 Jun 2017 20:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to Could not load Spatialite extension in QT5.9 on Thu, 08 Jun 2017 20:49:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/mca4213">@<bdi>MCA4213</bdi></a> ! I'm trying to do exactly the same but for Android. I was struggling  to compile qSqlite plugin. I followed all your steps and now I have my qSqlite plugin well compiled.</p>
<p dir="auto">I took from <a href="https://www.gaia-gis.it/fossil/libspatialite/index" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> a precompiled spatialite version for Android and then in Qt I run</p>
<pre><code>QSqlQuery spatialiteSqlQuery(db);
spatialiteSqlQuery.prepare("SELECT load_extension(\"libjsqlite\")");
</code></pre>
<p dir="auto">but I'm still getting an error and I cannot load spatialite extension.</p>
<pre><code>QSqlError("1", "Unable to fetch row", "not authorized")
</code></pre>
<p dir="auto">Could you give me some help? Am I doing something wrong?</p>
<p dir="auto">Thanks,<br />
Fernando</p>
]]></description><link>https://forum.qt.io/post/398324</link><guid isPermaLink="true">https://forum.qt.io/post/398324</guid><dc:creator><![CDATA[Ferni]]></dc:creator><pubDate>Thu, 08 Jun 2017 20:49:01 GMT</pubDate></item><item><title><![CDATA[Reply to Could not load Spatialite extension in QT5.9 on Thu, 08 Jun 2017 16:03:24 GMT]]></title><description><![CDATA[<p dir="auto">The problem was with my compiled library (still i don't know why?), and also with the mod_spatialite that I downloaded. This last one when we use it with the visual studio need a replacement for the libstdc++_64-6.dll because it will cause crash.</p>
<p dir="auto">My problem was here, the one that I used was not the good one, and was causing the The specified procedure could not be found, so I downloaded the x86_64-5.3.0-release-win32-seh-rt_v4-rev0 and I used the libstdc++-6.dll (I changed the name to libstdc++_64-6.dll) with the  libgcc_s_seh-1.dll. I also changed the libxml2-2.dll with another one that I compiled before.</p>
<p dir="auto">Then I changed the qSqlite pluginn as follow:</p>
<ul>
<li>open the "Qt5.9.0\5.9\Src\qtbase\src\3rdparty\sqlite" folder and change the sqlite3.c as following:</li>
</ul>
<p dir="auto">1- comment or remove the  "#define SQLITE_OMIT_LOAD_EXTENSION 1"</p>
<p dir="auto">2-add:</p>
<pre><code>#ifndef SQLITE_ENABLE_LOAD_EXTENSION
#define SQLITE_ENABLE_LOAD_EXTENSION 1
#endif
</code></pre>
<p dir="auto">3- go the "static int openDatabase(  const char *zFilename,sqlite3 **ppDb,  unsigned int flags, const char *zVfs)"  function and add "| SQLITE_LoadExtFunc" to SQLITE_ENABLE_LOAD_EXTENSION as following:</p>
<pre><code>#ifdef SQLITE_ENABLE_LOAD_EXTENSION
                 | SQLITE_LoadExtension | SQLITE_LoadExtFunc
#endif
</code></pre>
<ul>
<li>
<p dir="auto">compile your plugin again using your compiler ( nmake in my case) in Qt5.9.0\5.9\Src\qtbase\src\plugins\sqldrivers\sqlite\<a href="http://sqlite.pro" target="_blank" rel="noopener noreferrer nofollow ugc">sqlite.pro</a></p>
</li>
<li>
<p dir="auto">call the following code to load your spatialite:</p>
</li>
</ul>
<pre><code>QSqlQueryModel sql;
sql.setQuery("SELECT load_extension('mod_spatialite')", db);
</code></pre>
]]></description><link>https://forum.qt.io/post/398277</link><guid isPermaLink="true">https://forum.qt.io/post/398277</guid><dc:creator><![CDATA[MCA4213]]></dc:creator><pubDate>Thu, 08 Jun 2017 16:03:24 GMT</pubDate></item></channel></rss>