Qt World Summit: Register Today!

Building SQL driver plugin

  • Hi,

    I want to implement an export to MS Excel application.
    For that I want to enable ODBC in Qt.
    I am testing it in an Ubuntu 16.04 laptop.
    For this I am following the guide : https://doc.qt.io/qt-5/sql-driver.html
    I downloaded the qt source - https://download.qt.io/official_releases/qt/5.10/5.10.1/si ngle/qt-everywhere-src-5.10.1.tar.xz
    And downloaded odbc driver plugin unixODBC-2.3.7 from http://www.unixodbc.org/.
    As per the guide, when I execute the command "qmake -- ODBC_PREFIX=/usr/local/unixODBC", it is showing the errors:

    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:8: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:9: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:10: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:11: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:12: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:13: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:14: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:15: Unknown test function: qtConfig
    qt-everywhere-src-5.10.1/qtbase/src/plugins/sqldrivers/sqldrivers.pro:16: Unknown test function: qtConfig

    Is there any work around to solve this issue?

  • Lifetime Qt Champion


    Use the full path to the qmake executable for the version of Qt you want to build the plugin for.

    Currently you are using the qmake version from your distribution which likely is from a Qt 4 development package.

  • Thank You very much SGaist. Using the qt5 qmake full path obtained from the source qt-everywhere-src-5.10.1, solved the issue.

  • Hi,
    Now I could build sql odbc driver plugin successfully, and the library binary file libqsqlodbc.so is created in the folder - qt-everywhere-src-5.10.1/qtbase/plugins/sqldrivers.

    And I copied the same .so file in ~/QtCreatorInstall/Tools/QtCreator/lib/Qt/plugins/sqldrivers.

    I could build a qt example project - tablemodel - successfully in QtCreator.

    But when I am running it is giving an error -

    QSqlDatabase: QODBC driver not loaded
    QSqlDatabase: available drivers:

    Any clues?

  • Lifetime Qt Champion

    @Sajeevan-K Why do you copy the driver into QtCreator installation directory?
    You should put it into your Qt installation plugins/sqldrivers

  • Hi jsulm,

    Thank You very much. Copying libqsqlodbc.so to qt installation plugins folder /usr/local/Qt-5.10.1/plugins/ solved the issue.

  • Banned

    This post is deleted!

  • Banned

    This post is deleted!

Log in to reply