Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. sqlite3 - compiling in spatialite support
Forum Updated to NodeBB v4.3 + New Features

sqlite3 - compiling in spatialite support

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 541 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Citizenfish
    wrote on last edited by
    #1

    My goal is to add spatialite support to the sqlite3 plugin for Qt. I don't want to load it as an extension as this relies on the user having it installed.

    I've added the following to qsql_sqlite.cpp in the class QSQLiteDriver::open

    const int res = sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL);
    
        //DB
    
        void *cache;
        cache = spatialite_alloc_connection();
        spatialite_init_ex(d->access,cache,0);
        qWarning("SpatiaLite version: %s\n", spatialite_version ());
    
        //DB END
    
        if (res == SQLITE_OK) {
    ...
    

    This builds without errors but when I run my application it crashes as soon as it reaches the spatialite_init_ex statement.

    So I tried another approach using :-

    spatialite_initialize();
    qWarning("SpatiaLite version: %s\n", spatialite_version ());
    

    Which is not the recommended approach. This does not crash and prints the spatilaite version to console. But the query:-

    'SELECT InitSpatialMetadata(1)'
    

    Gives an error that InitSpatialMetadata is an unknown function.

    Can anyone help me get spatialite working via this plugin? I am developing on MacOSX but want to be able to distribute to multiple platforms. My crash report begins as follows:-

    System Integrity Protection: enabled
    
    Crashed Thread:        0  Dispatch queue: com.apple.main-thread
    
    Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY
    
    Termination Signal:    Segmentation fault: 11
    Termination Reason:    Namespace SIGNAL, Code 0xb
    Terminating Process:   exc handler [43100]
    
    VM Regions Near 0:
    --> 
        __TEXT                 0000000100b15000-0000000100c3d000 [ 1184K] r-x/r-x SM=COW  /Users/USER/*/servalan_2020_core.app/Contents/MacOS/servalan_2020_core
    
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   ???                           	000000000000000000 0 + 0
    1   libsqlite3.0.dylib            	0x0000000103f8dafc sqlite3Malloc + 64
    2   libsqlite3.0.dylib            	0x0000000103fa0385 dbMallocRawFinish + 17
    3   libsqlite3.0.dylib            	0x0000000103f956ce sqlite3DbMallocZero + 23
    4   libsqlite3.0.dylib            	0x0000000103f9c91d sqlite3FindFunction + 332
    5   libsqlite3.0.dylib            	0x0000000103f9c69e sqlite3CreateFunc + 528
    6   libsqlite3.0.dylib            	0x0000000103f9c266 createFunctionApi + 218
    7   libsqlite3.0.dylib            	0x0000000103f9c30e sqlite3_create_function_v2 + 26
    8   libspatialite.7.dylib         	0x000000010f4cec96 register_spatialite_sql_functions + 102
    9   libspatialite.7.dylib         	0x000000010f51a69b spatialite_init_ex + 107
    10  libqsqlite.dylib              	0x000000010f10be1c QSQLiteDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) + 396 (qsql_sqlite.cpp:794)
    11  org.qt-project.QtSql          	0x000000010b7c91c5 QSqlDatabase::open() + 53 (qsqldatabase.cpp:758)
    12  libqmllocalstorageplugin.dylib	0x000000010b7b8d13 QQuickLocalStorage::openDatabaseSync(QQmlV4Function*) + 3635
    13  libqmllocalstorageplugin.dylib	0x000000010b7b9376 QQuickLocalStorage::qt_metacall(QMetaObject::Call, int, void**) + 54 (plugin.moc:111)
    14  org.qt-project.QtQml          	0x00000001031cc35c QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const + 1388 (qv4qobjectwrapper.cpp:2123)
    15  org.qt-project.QtQml          	0x00000001031e5ad5 QV4::Moth::VME::interpret(QV4::CppStackFrame*, QV4::ExecutionEngine*, char const*) + 4469 (qv4vme_moth.cpp:754)
    16  org.qt-project.QtQml          	0x00000001031e4842 QV4::Moth::VME::exec(QV4::CppStackFrame*, QV4::ExecutionEngine*) + 130 (qv4vme_moth.cpp:463)
    17  org.qt-project.QtQml          	0x000000010318cf25 QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*) + 341 (qv4function.cpp:71)
    18  org.qt-project.QtQml          	0x00000001032fefde QQmlJavaScriptExpression::evaluate(QV4::CallData*, bool*) + 622 (qqmljavascriptexpression.cpp:215)
    19  org.qt-project.QtQml          	0x00000001032b90b6 QQmlBoundSignalExpression::evaluate(void**) + 1014 (qqmlboundsignal.cpp:223)
    20  org.qt-project.QtQml          	0x00000001032b9888 QQmlBoundSignal_callback(QQmlNotifierEndpoint*, void**) + 424 (qqmlboundsignal.cpp:357)
    21  org.qt-project.QtQml          	0x00000001032e6a25 QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**) + 581 (qqmlnotifier.cpp:105)
    22  org.qt-project.QtCore         	0x00000001039b2688 void doActivate<false>(QObject*, int, void**) + 120 (qobject.cpp:3768)
    23  org.qt-project.QtQml          	0x0000000103318cad QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) + 1341 (qqmlobjectcreator.cpp:1440)
    24  org.qt-project.QtQml          	0x00000001032af789 QQmlComponentPrivate::complete(QQmlEnginePrivate*, QQmlComponentPrivate::ConstructionState*) + 73 (qqmlcomponent.cpp:971)
    25  org.qt-project.QtQml          	0x00000001032ad6e6 QQmlComponentPrivate::completeCreate() + 102 (qqmlcomponent.cpp:1006)
    26  org.qt-project.QtQml          	0x00000001032aefc5 QQmlComponent::create(QQmlContext*) + 69 (qqmlcomponent.cpp:811)
    27  org.qt-project.QtQml          	0x000000010330926a QQmlApplicationEnginePrivate::finishLoad(QQmlComponent*) + 474
    28  org.qt-project.QtQml          	0x00000001033096f2 QQmlApplicationEngine::load(QUrl const&) + 34 (qqmlapplicationengine.cpp:264)
    29  com.yourcompany.servalan-2020-core	0x0000000100b1a6a5 main + 133 (main.cpp:15)
    30  libdyld.dylib                 	0x00007fff679dacc9 start + 1
    

    Any help or pointers gratefully received.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How exactly are you setting up SQLite and spatialite ?
      Did you rebuild the Qt SQLite plugin ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How exactly are you setting up SQLite and spatialite ?
        Did you rebuild the Qt SQLite plugin ?

        C Offline
        C Offline
        Citizenfish
        wrote on last edited by
        #3

        @SGaist I am recompiling the QT sqlite3 plugin and including spatialite directly.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you show how you do that ?

          Did you try starting your application with the QT_DEBUG_PLUGINS environment variable set to 1 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved