Qt plugins MySQL in Raspbian

  • Hi, im started an application on Qt 5 on my Raspberry PI2.
    I need to use MySQL but the problem is i don't know how to build plugins SQL on raspbian. I do it on Windows & Ubuntu 14.04.

    So i used this command :

    sudo $PathOfQmake/qmake "INCLUDEPATH+=$PathMySQL/include" "LIBS+=-L $PathMySQL/lib -lmysqlclient_r" mysql.pro

    And i got this error nowadays :

    Makefile:386: recipe for target ' .obj/qsql_mysql.o' failed
    make : *** [.obj/qsql_mysql.o] Error 1

    Thank you in advance for help me.

  • Moderators

    Can you please post the whole build log not just these two lines?
    The actual error message must be before this lines.

  • make
    g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -I/usr/include/mysql -O2 -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++ -I. -I/usr/lib/arm-linux-gnueabihf/qt5/MySQL/includeLIBS+=/usr/lib/arm-linux-gnueabihf/qt5/MySQL/lib -I-lmysqlclient_r -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSql/5.3.2 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSql/5.3.2/QtSql -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSql -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore/5.3.2 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore/5.3.2/QtCore -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -I.moc -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
    ../../../sql/drivers/mysql/qsql_mysql.cpp: In constructor ‘QMYSQLDriverPrivate::QMYSQLDriverPrivate()’:
    ../../../sql/drivers/mysql/qsql_mysql.cpp:82:51: error: ‘MySqlServer’ is not a member of ‘QSqlDriver’
             preparedQuerysEnabled(false) { dbmsType = QSqlDriver::MySqlServer; }
    Makefile:386: recipe for target '.obj/qsql_mysql.o' failed
    make: *** [.obj/qsql_mysql.o] Error 1

    I got this

  • Moderators

    It looks like you have the same issue (mixing Qt versions):

  • I will try a new installation of Qt & MySQL. I will answer you later. Thank for help @jsulm

  • Well, i got a new problem now. I download qt for linux, but the problem is, i can't lunch the .run

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can't use the installer on the Raspberry Pi. The Pi uses an ARM processor and the installers are build of x86/x86_64.

    Did you compile Qt for raspbian or are you using a package from the distribution ?

  • @SGaist Im using packages from the distribution. And i try to compil with Qt src and MySQL

  • Lifetime Qt Champion

    I just re-read your qmake line to build the plugin. You have a space between -L and your path which is wrong. The -L and -l options both require to have their argument right after.

  • @SGaist I do it again and no error, after the command make install. He said he creat the lib .so on $PathOfQt5/plugins/

    And when i tried to run my app he said again QSQLDatabase QMYSQL driver not loaded
    & QSQLDatabase : available drivers : QSQLITE

    Can i use the lib for ubuntu 14.0.4 for my raspberry ?

  • Lifetime Qt Champion

    No you can't, they are not from the same architecture. You have to compile the plugin with the Qt you are using for your RPi.

  • @SGaist Ok, i do it and not work at all...
    with the same error in Qt ...

    QSQLDatabase QMYSQL driver not loaded
    & QSQLDatabase : available drivers : QSQLITE

  • Lifetime Qt Champion

    Did you check that the plugin was properly installed in your device ?

  • @SGaist Yep he did. Should i copy/paste on my debug folder ?

  • Lifetime Qt Champion

    He did ? Who's that ?

    What do you mean by copy/past on my debug folder ?

  • @SGaist @SGaist Sorry for my english :]
    I mean yeah i got the good drivers.
    And my question is : should i copy / paste the lib on my projet folder (in debug / release) or something else ?

  • Lifetime Qt Champion

    No, they should be in Qt's installation folder under plugins/sqldrivers/

  • @SGaist Yeah, they are in the folder sqldrivers as you said. I really don't know how to help you with some indications... :/

  • Lifetime Qt Champion

    What do you get if your run ldd libqsqlmysql.so on your RPi ?

  • @SGaist I got this :

    pi@raspberrypi:/usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers $ ldd libqsqlmysql.so
    linux-vdso.so.1 (0x7ec39000)
    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f42000)
    libmysqlclient.so.18 => /usr/lib/arm-linux-gnueabihf/libmysqlclient.so.18 (0x76c1a000)
    libQt5Sql.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Sql.so.5 (0x76bd4000)
    libQt5Core.so.5 => /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5 (0x7674f000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76673000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76532000)
    /lib/ld-linux-armhf.so.3 (0x54b8f000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76509000)
    libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x764e2000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x764cf000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76454000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76427000)
    libicui18n.so.52 => /usr/lib/arm-linux-gnueabihf/libicui18n.so.52 (0x76266000)
    libicuuc.so.52 => /usr/lib/arm-linux-gnueabihf/libicuuc.so.52 (0x7611e000)
    libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0x7601b000)
    librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76004000)
    libicudata.so.52 => /usr/lib/arm-linux-gnueabihf/libicudata.so.52 (0x74987000)
    libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x74913000)

  • Lifetime Qt Champion

    Looks fine… Can you start your application with QT_DEBUG_PLUGINS=1 ? To see what happens when your application loads the plugins.

  • @SGaist I go this about Qt plugins for mysql :

    Got keys from plugin meta data ("QSQLITE")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlmysql.so"
    Found metadata in lib /usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
        "className": "QMYSQLDriverPlugin",
        "debug": false,
        "version": 328450
    Got keys from plugin meta data ("QMYSQL3", "QMYSQL")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlpsql.so"
    Found metadata in lib /usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlpsql.so, metadata=
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
        "className": "QPSQLDriverPlugin",
        "debug": false,
        "version": 328960
    In /usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlpsql.so:
      Plugin uses incompatible Qt library (5.5.0) [release]
    "Le plugin '/usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlpsql.so' utilise une bibliothèque Qt incompatible. (5.5.0) [release]"
             not a plugin
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/sqldrivers" ...
    loaded library "/usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlite.so"

  • Lifetime Qt Champion

    Looks like you either have two different version of Qt installed or you build your plugin with a different version of Qt than the one you originally built.

  • @SGaist Ok, i will try a new install of Qt with this tutorial https://wiki.qt.io/RaspberryPi2EGLFS
    Then a new install of MySql header & lib files. I will inform you about progress of this. I hate Qt on raspbian (joke ofc) :D

  • Hello,

    I know this thread is old but I came here with the same problem and managed to solve it.

    By installing libqt5sql5-mysql with $ apt-get install libqt5sql5-mysql

    Happy coding ! :)

Log in to reply

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