1

I'm completely stuck with loading extensions in Qt's SQLite driver. I've done all steps from this 'how to'. Just changed SQLITE_ENABLE_LOAD_EXTENSION to DSQLITE_ENABLE_LOAD_EXTENSION.
After that I'm trying to run following code in my app:

QSqlQuery tSqlQuery;
QString sql_command_text;
sql_command_text = QString("SELECT load_extension(\"libspatialite-4.dll\")");
if(!tSqlQuery.exec(sql_command_text))
    qDebug() << tSqlQuery.lastError().text();

And qDebug gives me this: "not authorized Unable to fetch row".

I'm using Qt 4.6.3

What am I doing wrong? I've read tons of articles but couldn't find any solution.


You can be sure in following things:

  1. I've done all steps from how-to
  2. I've rebuild DLLs and replaced them
tema
  • 1,115
  • 14
  • 33
  • 1
    "Just changed SQLITE_ENABLE_LOAD_EXTENSION to DSQLITE_ENABLE_LOAD_EXTENSION". Why? Are you it's correct? – Frank Osterfeld Nov 30 '13 at 22:55
  • @FrankOsterfeld It was my mistake. But since I've changed it to SQLITE_ENABLE_LOAD_EXTENSION new error came: The specified module could not be found. Unable to fetch row. Btw, I've placed libspatialite.dll to source folder and to debug folder as well – tema Dec 01 '13 at 09:38
  • 1
    The remaining issue looks identical to what's discussed here then: http://stackoverflow.com/questions/8590599/sqlite-load-extension-fail-for-spatialite-in-python – Frank Osterfeld Dec 01 '13 at 10:32

1 Answers1

0

When I face this problem I've solved it this way: Add in Src\qtbase\src\3rdparty\sqlite\sqlite3.c next lines:

#ifndef SQLITE_ENABLE_LOAD_EXTENSION
    # define SQLITE_ENABLE_LOAD_EXTENSION 1
#endif

Added it somewhere near 150 line.

Removed from file Src\qtbase\src\3rdparty\sqlite.pri from DEFINES:

SQLITE_OMIT_EXTENSION

Leave it like this:

DEFINES += SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_RTREE

then cd command line (yeah, I'm at Win) to Src\qtbase\src\plugins\sqldrivers\sqlite and execute next commands:

mingw32-make -j
mingw32-make install

flag -j makes make use all available cores for compiling, and install copy resulted dll to plugins\sqldrivers\sqlite dir (the place where all others dll's keep) of qt installation.

On linux (Ubuntu 14.10) I had to add this line in sqlite.pro before compiling:

LIBS=-ldl
MadisonTrash
  • 5,444
  • 3
  • 22
  • 25