QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits
First and foremost, double check that you have the packages containing libssl.so
, libcrypto.so
and libmysqlclient_r.so
installed (looks like you have this last one, it's extremely likely you also have the first two, but just double check).
Then, your problem is that you have those shared objects with a different SONAME, sign that they're binary incompatible with the plugin shipped with Qt, which therefore needs to be recompiled.
Therefore:
install the development versions of the packages found above (
libssl-dev
,mysql-client-dev
or similar).run the
MaintenanceTool
from your Qt installation, and be sure to select to install Qt's source code too.Go in
QTDIR/5.6/Src/qtbase/src/plugins/sqldrivers/mysql/
.Run the right
qmake
, i.e. the one coming from that installation of Qt (not the system wide one or similar). Best way to be sure is providing the full path to it:QTDIR/5.6/gcc_64/bin/qmake
.Run
make
. Hopefully this will just work™; if it complains about some missing libraries, install them and rerunmake
.This should now have produced a new
libqsqlmysql.so
plugin; overwrite the old one with this new one.
QMYSQL driver available but not loaded
ok it worked just by copying the sqldrivers
folder to my debug folder and it worked!
QMYSQL available but not load
I have reopened the question why the steps in the @peppe answer need to be updated for recent versions of Qt.
Steps:
Install the development versions of the packages found above:
libmysqlclient-dev
Run the MaintenanceTool from your Qt installation, and be sure to select to install Qt's source code too, or clone the project using:
git clone -b YOUR_QT_VERSION https://github.com/qt/qtbase.git
or
git clone -b YOUR_QT_VERSION git://code.qt.io/qt/qtbase.git
in this case YOUR_QT_VERSION=5.13.2)
Go in QTDIR/QT_VERSION/Src/qtbase/src/plugins/sqldrivers/
Run the right qmake, i.e. the one coming from that installation of Qt (not the system wide one or similar). Best way to be sure is providing the full path to it:
QTDIR/QT_VERSION/gcc_64/bin/qmake sqldrivers.pro
Run
make && make install
Qt5.2 can find the mysql driver but can not load it
Thanks for the answer, but the problem is not because I lack the qsqlmysql.dll but I don't have the libmysql.dll(looks like this dll do not come with win7).
Here is a video which show you how to install mysql
[Qt][QMYSQL] Deployed app - Driver not loaded
There are at least 3 possible solutions:
- Find all .dll paths are correct with your favourite process monitor
- Make sure all .dll is in the same arch as your .exe, which is x86 (32bit)
- Debug with QPluginLoader
Cannot load SQL driver in Visual C++ (but loads in QtCreator)
For anyone else who bumped into this problem I have to say this - it is much easier to use one of the packages containing QT pre-built binaries for Visual C++ than trying to build it yourself. And the Qt driver (the 4.3 version at least) is awfully hard to get to work (on some machines it works like a charm but on others it can't find the driver, using the same code and binaries), so you are much better off using a dedicated MySql library.
Related Topics
How Can Cstring Be Passed to Format String %S
Application Has Failed to Start Because Msvcp100D.Dll Was Not Found, Reinstalling App May Work
How to Check If a File Has Been Opened by Another Application in C++
Why Infinite Recursion Leads to Seg Fault
Calculate A*A Mod N Without Overflow
Std::Pow Produce Different Result in 32 Bit and 64 Bit Application
Interfacing C++11 Array with Cython
C++ When Is It Ok to Extend the 'Std' Namespace
C++ Expression Must Have a Constant Value
Const Variable Changed with Pointer in C
C/C++: Is This Undefined Behavior? (2D Arrays)
Cartesian Product of Several Vectors
Initialize Base Class with No Default Constructor in Constructor of Derived Class
Get a Reverse Iterator from a Forward Iterator Without Knowing the Value Type
Std::Remove_If - Lambda, Not Removing Anything from the Collection