libmysql.dll for 64bit Qt w/ MSVS2017 compiler - c++

I was always working with MinGW and all I had to do to not get the infamous output was to copy a 32bit libmysql.dll file to where the executable resides:
QSqlDatabase: MYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Now I'm trying to compile my application with MSVS2017 64bit compiler. I've tried to use both the 32bit and 64bit libmysql.dll files but with no luck - I'm getting the warnings and QSqlDatabase won't open. I've found this website: https://wiki.qt.io/How_to_load_a_sql_driver_correctly but it seems to be outdated and vague. Any known solution to the problem?

With MSVS you need qsqlmysql4.dll, usually need to build your MySQL drives from sources, you can follow Qt documentation How to Build the QMYSQL Plugin on Windows to do that.

Related

Qt: Windows 10: QMYSQL driver not loaded

In Short: I am trying to link my Qt5.5 to MySQL but it is not working.
The long story begins when I tried to use MySQL as in:
QSqlDatabase theDatabase = QSqlDatabase::addDatabase("QMYSQL");
But when I run my application, I get the following messages:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
At this point, I looked online to see how to fix this.
Then I found on Qt Documentation that I need to build the MySQL plugin. So, I followed the guidance:
I donwloaded mysql-installer-community-5.7.19.0
I tried to instal MySQL. However, during the installation, there was no Libs & Include Files Module to install !!
But I continued the installation and run MySQL57 succesfully as a service locally.
I could not of course build the plugin because there is not sqldrivers folder in my installed files.
I started looking all over the internet for solution. Then:
According to this youtube answer, I needed to copy libmysql.dll from C:\Program Files\MySQL\MySQL Server 5.7\bin to C:\Qt\Qt5.5.1\5.5\mingw492_32\bin
I run my application, but again I have the same error !! So:
I copied the file libmysql.dll from C:\Program Files\MySQL\MySQL Connector.C 6.1\lib to the same location C:\Qt\Qt5.5.1\5.5\mingw492_32\bin,
However, again I have the same error.
I am now stuck, don't know what to do.
P.S.: I have sql in my .pro file in Qt-application
My version is QT 5.11.1. I met same problem.
I copied libmysql.dll
from
C:\Program Files\MySQL\MySQL Server 5.7\lib
to
C:\Qt\Qt5.11.1\5.11.1\mingw53_32\bin.
Finally,I succeeded.
Download the 32-bit version of libmysql.dll; check here for details: qt 5.8 sql connection error:QMYSQL driver not loaded on windows 10

Qt Driver Postgresql available but not loaded

I'm trying to make a sample project, to read the data in my database.
I'm using Qt 5.8 on Windows 10, with mingw 32 bits compiler. Postgresql 9.6 32 bits.
I have the error :
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I tried to add in my Path:
-PostgresPath\
-PostgresPath\include
-PostgresPath\bin
-PostgresPath\lib
I tried to copy libeay32.dll, libintl-8.dll, libpq.dll, ssleay32.dll in QTPath\5.8\mingw53_32\bin.
I tried to add libpq.dll, qsqlpsql.dll and qsqlpsqld.dll in my project folder but it doesn't help.
Do you have any advice ?
Thanks.
Maybe you do not have the exact QPSQL plugin version you actually use for development (for example due to Qt framework upgrading etc.), so the plugin exists but cannot be loaded. Try to manually build the Qt PSQL driver plugin. Download the exact version of Qt source code (5.8.0 in your case) and run following commands.
I assume that PostgreSQL was installed in C: \ psql, and the Qt source code is in% QTDIR%, build the plugin as follows:
cd %QTDIR%\src\plugins\sqldrivers\psql
qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
nmake
This works for me when I had similar problem.

QSqlDatabase: QMYSQL driver not loaded on Mac OS

I've already solved this problem on Windows and some Linux flavors, now is Mac time. It all starts with the following:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Then the solution should be more or less what is pointed in the following links i.e.:
MySQL for Qt on Mac
QSqlDatabase: QMYSQL driver not loaded on Xubuntu 16.04 64bits
QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits
In the end a new version of (debug and release) the lib should be produced, then is a matter of replacing the old one by the new one and everything will work from now on.
I just did that and the problem is that the new lib (found in ~Qt/5.7/Src/qtbase/plugins/sqldrivers), the one just compiled with
~/Qt/5.7/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql-5.6.17-osx10.7-x86_64/include/" "LIBS += -L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/"
make
have the same size as the older (found in ~Qt/5.7/clang_64/plugins/sqldrivers). I mean, the lib just compiled is the same as the one already there. And I still get the QSqlDatabase: QMYSQL driver not loaded.
Can some one please put some light here? What's going on?
After some time I found (here) that
install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib
and
install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
helps.
I have some understanding of this but I'll leave it open to someone more knowledgeable in the field to give the details.
The critical part is to:
~/Qt/5.8/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql-5.6.17-osx10.7-x86_64/include/" "LIBS += -L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/" mysql.pro
make
And then:
cp ~/Qt/5.8/Src/qtbase/plugins/sqldrivers/ ~/Qt/5.8/clang_64/plugins/sqldrivers/

Qt MYSQL not working on ubuntu 15.10

I'm trying to get MYSQL working via Qt on Ubuntu 15.10, however I am having an issue when loading the plugin. I'm using the latest Qt, downloaded from their website (Qt5.6.0) but I am getting the following error when launching the application:
Got keys from plugin meta data ("QPSQL7", "QPSQL")
loaded library "/home/rob/Qt5.6.0/5.6/gcc_64/plugins/sqldrivers/libqsqlmysql.so"
QLibraryPrivate::loadPlugin failed on "/home/rob/Qt5.6.0/5.6/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/rob/Qt5.6.0/5.6/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)"
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
The issue is, that libmysqlclient_r.so.16 is not even part of the ubuntu 15.10 linux distribution, which uses instead libmysqlclient_r.so.18.
I've read somewhere that clearing Qt's plugin cache may help this, but I could not find out how to do that.
What steps should I take to fix this issue?

Qt QPSQL driver problem

I'm trying to connect postgresql with Qt SQL module. I successfully compile psql driver(src\plugins\sqldrivers\psql). But when i try to connect postgresql, i get this message;
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL3 QMYSQL QODBC3 QODBC QPSQL7 QPSQL
I'm using PostgreSQL 8.3, Qt 4.7.1 and Visual Studio 2008 in Windows XP SP3.(I also try this, but didn't help)
Did you compile the release and debug versions of the plugin? The output of the dependency walker looks like you work with the debug version. You should have qsqlpsql4.dll and qsqlpsqld4.dll in the %QTDIR%\plugins\sqldrivers directory. You can check the plugin path that is used in your program with: QString QLibraryInfo::location ( QLibraryInfo::PluginsPath );