Why can't Qt be installed with SQLite that has load_extension enabled?



  • Several apps that I have that use Qt also use Sqlite. Also, these apps require that Sqlite be able to load extension functions. However, this ability is disabled in the version of Sqlite that is compiled with Qt. So, every time that I want to use a new version of Qt, I have to download the source and recompile QT and the Sqlite plugin. Not only does this take a lot of time, it also eats up huge amounts of disk space. Generally, for my purposes, I have not found it necessary to compile Qt from source for any other reason than to be able to compile the Sqlite plugin.

    A simple solution to this problem could be made by shipping Qt with 2 versions of the Sqlite plugin. One, configured just as at present and the 2nd configured to use a system Sqlite. The user would then be free to use Sqlite of any version configured to his/her needs.

    I am sure that any Sqlite user, including users of Spatialite would appreciate such an enhancement to Qt.


  • Lifetime Qt Champion

    Hi,

    You don't need to rebuild Qt to rebuild the SQLite plugin. Build the plugin like described here.



  • @SGaist thanks, I'll try that next time, however it still means that one must download the source package.



  • I built the plugin with this script:

    CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
    
    set QTDIR="C:\Qt5\5.6\Src\"
    
    cd %QTDIR%\qtbase\src\plugins\sqldrivers\sqlite
    
    %QTDIR%\..\msvc2013_64\bin\qmake "INCLUDEPATH+=C:/Progra~1/Sqlite3_3_13/src" "LIBS+=C:/Progra~1/Sqlite3_3_13/SQLITE3.LIB" sqlite.pro
    
    nmake
    
    

    This did not work. qmake added the define "ENABLE_LOAD_EXTENSION" but failed to delete "OMIT_LOAD_EXTENSION"

    I solved this problem by manually editing the sqlite.pro file referenced by qmake by adding:

    DEFINES -= SQLITE_OMIT_LOAD_EXTENSION
    DEFINES += SQLITE_ENABLE_LOAD_EXTENSION
    

    This time a sqlite plugin was compiled with the options I wanted but this was not really what I wanted. I wanted to use a system sqlite. So it looks like I must run the config program with the "-system-sqlite" configuration parameter. So it looks like there is no way to do this without running configure.


  • Lifetime Qt Champion

    Since you are editing sqlite.pro anyway, why not disable the !system-sqlite part and put the include/link path needed for your system sqlite ?



  • This is what qtbase/src/plugins/sqlite/sqlite.pro looks like after running configure with the -system-sqlite parameter specified.

    TARGET = qsqlite
    
    SOURCES = smain.cpp
    OTHER_FILES += sqlite.json
    include(../../../sql/drivers/sqlite/qsql_sqlite.pri)
    
    PLUGIN_CLASS_NAME = QSQLiteDriverPlugin
    include(../qsqldriverbase.pri)
    
    

    Here is the partial output of configure:

    QMAKESPEC...................win32-msvc2013 (commandline)
    Architecture................x86_64, features: sse sse2
    Host Architecture...........x86_64, features: sse sse2
    Maketool....................nmake
    Debug build.................yes (combined)
    Default build...............debug
    Force debug info............no
    Force optimized tools.......no
    C++ language standard.......auto
    Link Time Code Generation...no
    Using PCH ..................yes
    Accessibility support.......no
    RTTI support................yes
    SSE support.................SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
    AVX support.................AVX AVX2
    AVX512 support..............<none>
    NEON support................no
    OpenGL support..............yes
    Large File support..........yes
    NIS support.................no
    Iconv support...............no
    Evdev support...............no
    Mtdev support...............no
    Inotify support.............no
    eventfd(7) support..........no
    Glib support................no
    CUPS support................no
    OpenVG support..............no
    SSL support.................no
    OpenSSL support.............no
    libproxy support............no
    Qt D-Bus support............runtime
    Qt Widgets module support...yes
    Qt GUI module support.......yes
    QML debugging...............yes
    DirectWrite support.........yes
    DirectWrite 2 support.......yes
    Use system proxies..........no
    
    QPA Backends:
        GDI.....................yes
        Direct2D................no
    
    Third Party Libraries:
        ZLIB support............qt
        GIF support.............plugin
        JPEG support............plugin
        PNG support.............yes
        DoubleConversion........qt
        FreeType support........yes
        Fontconfig support......no
        HarfBuzz support........qt
        PCRE support............qt
        ICU support.............no
        ANGLE...................yes
        Dynamic OpenGL..........no
    
    Styles:
        Windows.................yes
        Windows XP..............yes
        Windows Vista...........yes
        Fusion..................yes
    
    Sql Drivers:
        ODBC....................no
        MySQL...................no
        OCI.....................no
        PostgreSQL..............no
        TDS.....................no
        DB2.....................no
        SQLite..................plugin (system)
        SQLite2.................no
        InterBase...............no
    
    Sources are in..............C:\Qt5\5.7\Src\qtbase
    Build is done in............C:\Qt5\5.7\Src\qtbase
    Install prefix..............C:\Qt5\5.7\Src\qtbase
    Headers installed to........C:\Qt5\5.7\Src\qtbase\include
    Libraries installed to......C:\Qt5\5.7\Src\qtbase\lib
    Arch-dep. data to...........C:\Qt5\5.7\Src\qtbase
    Plugins installed to........C:\Qt5\5.7\Src\qtbase\plugins
    Library execs installed to..C:\Qt5\5.7\Src\qtbase\bin
    QML1 imports installed to...C:\Qt5\5.7\Src\qtbase\imports
    QML2 imports installed to...C:\Qt5\5.7\Src\qtbase\qml
    Binaries installed to.......C:\Qt5\5.7\Src\qtbase\bin
    Arch-indep. data to.........C:\Qt5\5.7\Src\qtbase
    Docs installed to...........C:\Qt5\5.7\Src\qtbase\doc
    Translations installed to...C:\Qt5\5.7\Src\qtbase\translations
    Examples installed to.......C:\Qt5\5.7\Src\qtbase\examples
    Tests installed to..........C:\Qt5\5.7\Src\qtbase\tests
    Include paths...............C:\Progra~1\Sqlite3_3_13\src
    Additional libraries........-LC:\Progra~1\Sqlite3_3_13
    Using internal configuration.
    
    Info: creating super cache file C:\Qt5\5.7\Src\.qmake.super
    
    
    Qt is now configured for building. Just run nmake.
    To reconfigure, run nmake confclean and configure.
    
    
    

    It does not appear to me that there is any change to the sqlite.pro file that would result in a sqlite plugin configured for system-sqlite.

    I tried using the qmake created by configure but got this result:

    C:\Qt5\5.7\Src\qtbase\src\plugins\sqldrivers\sqlite>%QTDIR%\qtbase\bin\qmake "IN
    CLUDEPATH+=C:/Progra~1/Sqlite3_3_13/src" "LIBS+=C:/Progra~1/Sqlite3_3_13/SQLITE3
    .LIB" sqlite.pro
    Project ERROR: No module claims plugin type 'sqldrivers'
    

    So how can you create a system sqlite plugin without recompiling QT from source?

    It still seems that if QT were shipped with an alternative sqlite driver that specifies system-sqlite it would make things easier. Alternatively, maybe a run-time parameter to open the plugin could have an extra parameter that specified using the system sqlite instead of the built-in one.


  • Lifetime Qt Champion

    The .pro file won't be changed.

    The QMAKE_CONFIG will contain system-sqlite which will be used to determine how the plugin will be built.

    Modify the .pro file to remove the check, add the LIBS, INCLUDEPATH and flags you need.

    There's an important difference between the use of the bundled SQLite and a system installed SQLite. The bundled one gets builtin the plugin.



  • What or where is QMAKE_CONFIG? Remove what check? I'm aware of the difference between the use of the bundled SQLITE and a system installed SQLITE but would like to know how to have QT use a system SQLITE without compiling it from source.


  • Lifetime Qt Champion

    QMAKE_CONFIG is populated by configure.

    The way it's described in the documentation I linked to. However the name of the lib might be sqlite3 rather that just sqlite



  • Back up to where I ran configure specifying -system_sqlite. Then I ran qmake on the sqlite.pro file and then nmake, It didn't work; I got an error that I documented there. I believe it requires some other library to be compiled also; maybe qt5sql.dll.


  • Lifetime Qt Champion

    Which qmake are you using ?



  • I used the qmake that was created when you run configure.


  • Lifetime Qt Champion

    Don't, use the qmake from the Qt version you want to build the plugin for.



  • That doesn't result in a system_sqlite plugin. Why don't you download a fresh copy of QT and you will see what I mean.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.