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:
Then, ran nmakeand nmake install and in the folder C:\Qt\5.14.2\msvc2017_64\plugins\sqldrivers, I found the following files.
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?)?
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!
Related
I'm trying to install GeoDjango in my Django project and got weird errors with GDAL.
Following Django documentation, I installed GDAL, GEOS, PROJ using OSGeo4W64, for specific, these are packages I selected to install on OSGeo4W64 setup:
gdal v2.3.2-2
geos v3.7.0-1
proj v5.2.0-1
I also set my environment variables as documented.
What error I got
At first when I started my Django project (using runserver), python tried to look for gdal202.dll and raised error Entry Point Not Found:
The procedure entry point sqlite3_column_origin_name could not be
located in the dynamic link library ...\osgeo4w64\bin\gdal202.dll
And one more error Ordinal Not Found with libcurl.dll (installed by OSGeo4W as dependencies):
The ordinal 361 could not be located in the dynamic link library
..\osgeo4w64\bin\libcurl.dll
and python raised error:
[WinError 182] The operating system cannot run %1
What I did
I fixed the first error by downgrade gdal version to gdal201.dll but still can not figure out how to solve the second error.
I tried download the latest Windows binary version of libcurl and replaced with but then I got another error raised by python:
[WinError 126] The specified module could not be found
I also checked for arch of my curl binary is x64 (the same as my python and OSGeo4W).
Hope someone one can help, thanks so much.
On Windows w/ Django and PyCharm, I began to receive the same error as one of your earlier ones, as described below:
The procedure entry point sqlite3_column_origin_name could not be located in the dynamic link library C:\Program Files\GDAL\gdal203.dll
Short-story solution that worked for me
Renamed: "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\DLLs\sqlite3.dll" to sqlite3.dll.bak
I used two tools to help me resolve this
Dependencies
Process Explorer 64
Steps used to correct
Use Dependencies to load up gdal203.dll and look for which DLL is used for sqlite3_column_origin_name
Used Process Explorer to determine which sqlite3.dll was being loaded into memory (welcome to DLL-hell). In my case it was in "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\DLLs"
Used Dependencies to examine the sqlite3.dll from Visual Studio
Exited PyCharm and renamed the Visual Studio DLL sqlite3.dll.bak to force it to load up the one according to my PATH order. Who knows what else I may have unintentionally broke by doing this. Future-me might hate me for this.
Starting with a new install of Windows 10, followed by installing PyCharm, Django, GeoDjango... it won't work without substantial troubleshooting in my experience. I think partly from DLL-hell and partly due to PyCharm's runnerw64.exe used to hook in the debugger.
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
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.
I have some trouble when I want to add a database.
_dataBase = QSqlDatabase::addDatabase("QPSQL");
After calling this method I have an error:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I include to PATH variable paths to:
PostgreSQL\9.3\bin
PostgreSQL\9.3\lib
PostgreSQL\9.3\include
Also I copy folder sqldrivers to Debug folder. Also tried to copy dlls drom this folder to Debug. Doesn't work either.
I came here googling because I had the same problem in Windows.
In my case to solve the issue I had to install PostgreSQL for Windows 32 bits since my Qt target was MinGW 32 bits.
Additionally, I had to add the PATH to the PostgreSQL bin and lib directories so Qt could find the right .dlls.
#SET PATH=C:\Program Files (x86)\PostgreSQL\9.6\bin\;C:\Program Files (x86)\PostgreSQL\9.6\lib\;%PATH%
The PATH can be set before launching Qt Creator or using the Qt Creator itself via the Build Environment in the Projects pane.
Add the system variable QT_DEBUG_PLUGINS=1 if you want to get full information of why the QPSQL driver has not been loaded.
Probably you will discover that Qt is not able to find it. Copy and paste the output here to know what exactly happens.
Use depends.exe on qsqlpsql.dll and found that this dll need libpq.dll from PostgreSQL\9.3\libfolder. Add libpq.dll to Debug folder and it works:)
Try pip install PyQt5 event if you already installed it using conda or installer. It helped me.
I got same problem with deploying Qt application (windeployqt didn't help). I had to copy more .dlls (libcrypto-1_1-x64.dll, libiconv-2.dll, libintl-8.dll, libpq.dll, libssl-1_1-x64.dll, libwinpthread-1.dll) from postgreSQL bin path (c:\Program Files\PostgreSQL\12\bin) next to .exe file (according to dependency walker).
Operating System: win7
compiler : mingw4.8(come with Qt5.2)
link to : Fedora core release 5, kernel 2.6.15-1.2054_FC5 smp on an i686
db = new QSqlDatabase();
db->addDatabase("QMYSQL");
db->setHostName("localhost");
db->setDatabaseName("myclinic");
db->setUserName("root");
db->setPassword(",trth12");
qDebug() << loader.errorString();
qDebug() << "drivers: "<< QSqlDatabase::drivers();
if (db->open())
qDebug() << "Success!";
else
qDebug() << db->lastError().text();
messages
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available
drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL 7 “The shared
library was not found.” drivers: (“QSQLITE”, “QMYSQL”, “QMYSQL3”,
“QODBC”, “QODBC3”, “QPSQL”, “QPSQL7”)
“Driver not loaded Driver not loaded”
You seem to be either missing the mysql plugin on your Windows or the proper mysql installation itself in which case you will need to get that done by installing all the necessary mysql libraries on your system where the plugin QtSql driver can recognize it.
The plugin should be available under the plugins/sqldrivers folder as a dll. You could also put it into an sqldrivers folder beside your application, so somethiing like this:
- yourapplication.exe
- sqldrivers/qsqlmysql4.dll
You would need to grab it somehow, or build it yourself. This is the explanation from the documentation how to do so:
How to Build the QMYSQL Plugin on Windows
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MySQL):
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
nmake
If you are not using a Microsoft compiler, replace nmake with make in the line above.
There is another problem with your code though. You should be using "127.0.0.1" instead of "localhost" for mysql databases.
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
I had the same Pb of you
Solution is:
The Qt MySQL drivers is already inside Qt5 (but not in the previous version!)
You just need the "libmysql.dll" next to your app exe (or in windows directory!) You find "libmysql.dll" in "mysql\mysqlX.X.XX\lib\opt" directory.
If Qt MySQL driver not found the libmysql.dll the error is the same as the driver is not found...
Good chance for the next!