1
votes

I know there are already many topics on this forum about this problem but I did not manage to solve mine following them.

My configuration is the following:

QT Version : 5.14.2 - mscv2017_64

Compiler: mscv amd64

My problem is that my application does not load the libmysql.dll. Here is what I have done:

I opened the command line MSCV 2017 64bits provided by qt and I initialized my environment using vcvarsall.bat amd64. Then I have built the sql driver as explained in the documentation.

Here is the result of the qmake call: enter image description here

Then, ran nmakeand nmake install and in the folder C:\Qt\5.14.2\msvc2017_64\plugins\sqldrivers, I found the following files. enter image description here

Then I added libmysql.dll in the folder where my the exe file of my application was created. I got this file from the mysql server installation folder C:\Program Files\MySQL\MySQL Server 8.0\lib.

Then I rebuilt my application, but I still have the same error appearing, saying that the driver was not loaded. I compiled using the QT_DEBUG_PLUGINS=1 flag and I got as an output:

"The plugin 'C:/Qt/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Thomas Bouchan/Documents/Personal/C++/SSVP/build-SSVP-project-Desktop_Qt_5_14_2_MSVC2017_64bit-Release/release/sqldrivers" ... Cannot load library C:\Qt\5.14.2\msvc2017_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found. QLibraryPrivate::loadPlugin failed on "C:/Qt/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\Qt\5.14.2\msvc2017_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found." QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7"

From this I don't know what to do, as in the specified folder, the dll is there... Is it a question of 64 or 32 bits? Shall I build the driver with another compiler (not amd64?)?

1
Cannot mix debug and release libraries: It is not a 32/64bit problem, but a Debug/Release problemking_nak
I agree but what can be wrong? I am running my application in Qt creator in debug mode and qsqlmysqld.dll is the debug dll...Thombou
Ah I see it is another Plugin, the MySQL has later a different message. Looks like a dependend DLL cannot be found. Can you try load the qsqlmysql.dll in dependency walker?king_nak

1 Answers

1
votes

I finally manage to get it working.

There was no issue with the compilation of the drivers, but the problem came from the libmysql.dll file. I don't know what happened with this dll but when I replaced it with the one downloaded the archive qsqlmysql.dll_Qt_SQL_driver_5.14.2_MSVC2017_64-Bit.zip. I only needed to replace the dll, not to use the plugins of the archive.

Opening the qsqlmysqld.dll with the dependency walker, I found out that two additional dlls files are required in libmysql.dll: LIBSSL-1_1-X64.dll and LIBCRYPTO-1_1-X64.dll. They can be found in the bin directory of the mysql server. In my case C:\Program Files\MySQL\MySQL Server 8.0\bin. Adding those files in the directory of the executable solves the problem. Thanks @king_nak for the tip!