Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded
-
Hi there !
I swear I've look a lot on Internet but I really don't find any solution for this simple issue.
I'm not a Qt expert.
I'm running Qt on my Debian 10.4 (kernel version 4.19.0).
As writted on this title I got an errorQSqlDatabase: QMYSQL driver not loaded
when I try to run my app.
I've a symlink to /usr/lib/x86_64-linux-gnu/libmysqlclient.so in ~/Qt/5.12.7/gcc_64/plugins/sqldrivers/ and ~/Qt/5.12.7/gcc_64/lib/.I've look with strace and it's looking for it in ~/Qt/5.12.7/gcc_64/plugins/sqldrivers/
And this is in my .pro file :QT += \ widgets sql quick bluetooth QTPLUGIN += qsqlite
Thank you by advance.
-
@sertux said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
QSqlDatabase: QMYSQL driver not loaded
Hello and welcome to QtForum, I think you have a library version issue, have you give the output of
ldd ~/Qt/5.12.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so
-
ldd /home/smv/Qt/5.12.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so
output :
linux-vdso.so.1 (0x00007ffd6daa2000) libmariadb.so.3 => /lib/x86_64-linux-gnu/libmariadb.so.3 (0x00007f2117a78000) libQtSql.so.4 => /lib/x86_64-linux-gnu/libQtSql.so.4 (0x00007f2117a32000) libQtCore.so.4 => /lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f2117728000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f21175a4000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f211758a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f21173c9000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f21173a6000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2117188000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2117183000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2117000000) libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f2116e54000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f2116d35000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2116d29000) /lib64/ld-linux-x86-64.so.2 (0x00007f2117b08000) libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f2116bfa000) libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f2116bdb000) libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f2116a57000) libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f2116844000) libnettle.so.6 => /lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f211680a000) libhogweed.so.4 => /lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f21167d1000) libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f211674e000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f21166da000) libffi.so.6 => /lib/x86_64-linux-gnu/libffi.so.6 (0x00007f21166d0000)
-
@sertux According to ldd output, loading the plugin should not be a problem, all dependencies are met...
Try to set environment variable
QT_DEBUG_PLUGINS=1
to see why Qt won't load the plugin.
You can also set it in your main(), just for test purpose:int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); qputenv("QT_DEBUG_PLUGINS", QByteArray("1")); ... // try to load mySQL plugin manually QPluginLoader loader; loader.setFileName("/home/smv/Qt/5.12.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so"); }
-
@KroMignon said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
According to ldd output, loading the plugin should not be a problem, all dependencies are met...
Really? I would say it's messed up:
libQtSql.so.4 => /lib/x86_64-linux-gnu/libQtSql.so.4 (0x00007f2117a32000)
libQtCore.so.4 => /lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f2117728000) -
@Christian-Ehrlicher said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
Really? I would say it's messed up:
Damn your are right!
@sertux you have a problem with your plugin:
...
libQtSql.so.5 => /home/smv/Qt/5.12.7/gcc_64/libQtSql.so.5 (...)
libQtCore.so.5 => home/smv/Qt/5.12.7/gcc_64/libQtCore.so.5 (...)
...
I think there is something going wrong during installation or your LD_LIBRARY_PATH setting may be wrong?!?Thanks @Christian-Ehrlicher !
-
@KroMignon
It seems there is a problem while loading the plugin..."Failed to extract plugin meta data from '/home/smv/Qt/5.12.7/gcc_64/plugins/sqldrivers/libqsqlmysql.so'"
not a plugin?? What am I supposed to do with this ?? I have libqsqlmysql.so in the right folder.
@KroMignon said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
@Christian-Ehrlicher said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
Really? I would say it's messed up:
Damn your are right!
@sertux you have a problem with your plugin:
...
libQtSql.so.5 => /home/smv/Qt/5.12.7/gcc_64/libQtSql.so.5 (...)
libQtCore.so.5 => home/smv/Qt/5.12.7/gcc_64/libQtCore.so.5 (...)
...
I think there is something going wrong during installation or your LD_LIBRARY_PATH setting may be wrong?!?Thanks @Christian-Ehrlicher !
Sorry but, what should I do with this information ?
I have no LD_LIBRARY_PATH but compiler is looking into the right folder.
And I don't have any libQtSql.so.5 or libQtCore.so.5 in /home/smv/Qt/5.12.7/gcc_64/Thank you for helping me !
-
@sertux We are trying to help you, as far as I understand you:
- you want to use mySQL plugin with Qt 5.12.7.
- you have installed Qt 5.12.7 into /home/smv/Qt/5.12.7/gcc_64/
- loading the plugin do not work.
What I try to find out is why, just as side note, I don't use Linux myself, I develop with Windows and Android, so it could happen that I made some mistakes.
One of this is, that I missed to add "lib" in my previous post
...
libQtSql.so.5 => /home/smv/Qt/5.12.7/gcc_64/lib/libQtSql.so.5 (...)
libQtCore.so.5 => home/smv/Qt/5.12.7/gcc_64/lib/libQtCore.so.5 (...)
...Sorry about that.
On your previous message with ldd output, it look likes your mysqlplugin want to used Qt 4.xx libraries not Qt 5. Are you sure you have done Qt 5.12.7 installation in the right way?
-
@KroMignon said in Error in qt 5.12.7 QSqlDatabase: QMYSQL driver not loaded:
@sertux We are trying to help you, as far as I understand you:
- you want to use mySQL plugin with Qt 5.12.7.
- you have installed Qt 5.12.7 into /home/smv/Qt/5.12.7/gcc_64/
- loading the plugin do not work.
What I try to find out is why, just as side note, I don't use Linux myself, I develop with Windows and Android, so it could happen that I made some mistakes.
One of this is, that I missed to add "lib" in my previous post
...
libQtSql.so.5 => /home/smv/Qt/5.12.7/gcc_64/lib/libQtSql.so.5 (...)
libQtCore.so.5 => home/smv/Qt/5.12.7/gcc_64/lib/libQtCore.so.5 (...)
...Sorry about that.
On your previous message with ldd output, it look likes your mysqlplugin want to used Qt 4.xx libraries not Qt 5. Are you sure you have done Qt 5.12.7 installation in the right way?
I've used Qt Maintenance Tool to install Qt5.12.7. And I've used apt-get to install mysql lib... Maybe this is not the right way to do it... ?
sorry for my english, that's not perfect :/ -
I'm pretty sure in Qt5.12.7 there will be not mysql plugin available with the maintainance tool due to legal reasons (in the opensource version at least). Make sure the plugin really matches your Qt installation.
-
@Christian-Ehrlicher I didn't use the maintenance tool to install mysql libs but I used Debian's package management tool (apt-get).
-
So when you don't use the Qt provided by your os then I'm pretty sure you have to compile it by yourself: https://doc.qt.io/qt-5/sql-driver.html
-
@Christian-Ehrlicher This is true... (I swear, I didn't see your post before to find this solution.
So I just add those commands I used for those it coul'd help :cd ~/Qt/5.12.7/Src sh configure -sql-mysql
Choose youre version
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.Which edition of Qt do you want to use? o
Accept license
Type 'L' to view the GNU Lesser General Public License version 3 (LGPLv3).
Type 'G' to view the GNU General Public License version 2 (GPLv2).
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.Do you accept the terms of either license? y
And be sure to see this line
MySql .................................. yes
cd qtbase/src/plugins/sqldrivers/mysql/ /home/smv/Qt/5.12.7/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro make install
That's it :)
Thanks everyone for your great help.