Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Using sqlite with a static build of Qt 5.9.4 in MSVC2017



  • Hi,

    I am currently in the process of migrating a legacy application to Qt 5.9.4 which uses SQlite.

    I have compiled a static version of Qt 5.9.4 with the new "--sql-sqlite" option, which generated a qsqlite.lib plugin in sqldrivers.

    If I link this library the application produces an error (QSQLITE driver not loaded). If I insert

    Q_IMPORT_PLUGIN(qsqlite)
    

    into my application I get a linker error:

    LNK2001	Unresolved symbol "struct QStaticPlugin const __cdecl qt_static_plugin_qsqlite(void)" (?qt_static_plugin_qsqlite@@YA?BUQStaticPlugin@@XZ)".
    
    

    Is there anything else I need to be doing? We are using the Qt Visual Studio Tools (so no qmake .pro file).

    Is it not possible to integrate sqlite in to static core directly (as was previously possible wit "--qt-sqlite" iirc)?



  • Ok, I think the correct import is:

    Q_IMPORT_PLUGIN(QSQLiteDriverPlugin)
    

    Is this documented somewhere (to make sure)?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It's explained in the Plugins Howto in Qt's documentation.



  • Hi, thanks for your reply.

    The article you linked does cover the use of static plugins but only in a qmake-environment (which I don't use). Also I could not find any reference to the actual plugin name (QSQLiteDriverPlugin) yet.


  • Lifetime Qt Champion

    What you can do is create a project using qmake that uses everything you need for your other application then inspect the generated visual studio project for the informations you need.


Log in to reply