QTDriver not Load
-
@lucaynnofrota said in QTDriver not Load:
set mysql=C:\Program Files\MySQL
You should avoid using paths with spaces.
-
@lucaynnofrota
I'm lost: Is your problem still that you don't start out in the right directory for yourqmake
command?? Because you have been showing lines like:C:\Users\lucya\Desktop\Qt Driver>cd D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\ C:\Users\lucya\Desktop\Qt Driver>qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\\lib\\libmysql.lib" -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\
Given that you seem to want to change the current directory to a path on a different drive from where you are, what do you think your first
cd
is accomplishing? On Windows/DOS it does not change the "current" directory (as you can see from the second line's prompt), it only changes the default directory on the other drive (D:
).You have to use
cd /d ...
orpushd ...
, or goD:
, if drive letter is different from current drive, if you want to change "the current directory" for theqmake
.Is this what this is all about?? Or maybe I'm going mad or don't have a clue what the issue is :)
-
@jsulm
Thanks for reply
I copied the files of interest to another folder to try to build. But it did not work.
Input:d: cd D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql qmake "INCLUDEPATH+=C:\Users\lucya\Desktop\Qt_Driver\include" "LIBS+=C:\Users\lucya\Desktop\Qt_Driver\libs" -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\ nmake C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql pause
Output:
D:\>cd D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\Users\lucya\Desktop\Qt_Driver\include" "LIBS+=C:\Users\lucya\Desktop\Qt_Driver\libs" -o Makefile D:\Qt\5.11.2\Src\qtbase\src\plugins\sqldrivers\ Info: creating stash file D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql\.qmake.stash Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... no Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>nmake C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql Microsoft (R) Program Maintenance Utility Version 14.16.27023.1 Copyright (C) Microsoft Corporation. All rights reserved. NMAKE : fatal error U1073: don't know how to make 'C:\Program~Files\MySQL\MySQL~Server~8.0\include\mysql' Stop. D:\Qt\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql>pause
What is "sub" in documentation?
-
-
Thanks for reply
http://doc.qt.io/qt-5/sql-driver.html
Exist this code in documentationcd $QTDIR/qtbase/src/plugins/sqldrivers qmake -- MYSQL_PREFIX=/usr/local make sub-mysql
What is this "sub"?
-
@lucaynnofrota It is a build target. Open the generated Makefile and search for sub-mysql there.
-
Hello, I have the same problem as @lucaynnofrota. I think I might be using the wrong commands to compile the MySQL plugin, although I have tried to follow the documentation. I'm on a Mac.
I've inputted in Terminal:cd /Volumes/Potato/apps/5.11.2/Src/qtbase/src/plugins/sqldrivers qmake -- MYSQL_PREFIX=/usr/local/mysql make sub-mysql
In which "apps" is the Qt folder I've accidentally renamed.
But whenever I try to execute this:#include <iostream> #include <QtSql> #include <QtCore> #include <QString> #include <QCoreApplication> using namespace std; int main(int argc,char *argv[]) { QCoreApplication a(argc,argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); bool ok = db.open(); if(ok) cout << "OK!\n"; qDebug() << db.lastError(); }
I get :
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 QSqlError("", "Driver not loaded", "Driver not loaded")
My .pro file is:
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG += qt QT += sql gui SOURCES += \ main.cpp
What am I doing wrong?
Thanks! -
Hi,
Add the
QT_DEBUG_PLUGINS
environment variable in the Run part of the Project panel. You'll have more information about why the plugins doesn't load. A wild guess would be that the application can't find the MySQL dlls at run time. -
Thanks for replying!
I've tried to set QT_DEBUG_PLUGINS to 1, and the output is:cd /; /Volumes/Potato/apps/Qt\ Creator.app/Contents/MacOS/../Resources/qtcreator_process_stub run /var/folders/sv/76q4jsns75g48tkx3b4g__3c0000gn/T/QtCreator.kFAuXu/stub-socket Press\ \<RETURN\>\ to\ close\ this\ window... /Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release /var/folders/sv/76q4jsns75g48tkx3b4g__3c0000gn/T/QtCreator.KiilXk 23590 /Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release/testsqlite QFactoryLoader::QFactoryLoader() checking directory path "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers" ... QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "className": "QSQLiteDriverPlugin", "debug": false, "version": 330498 } Got keys from plugin meta data ("QSQLITE") QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlite_debug.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "className": "QSQLiteDriverPlugin", "debug": true, "version": 330498 } Got keys from plugin meta data ("QSQLITE") QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "className": "QMYSQLDriverPlugin", "debug": false, "version": 330498 } Got keys from plugin meta data ("QMYSQL3", "QMYSQL") QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "className": "QMYSQLDriverPlugin", "debug": true, "version": 330498 } Got keys from plugin meta data ("QMYSQL3", "QMYSQL") QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "className": "QPSQLDriverPlugin", "debug": false, "version": 330498 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() looking at "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib" Found metadata in lib /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlpsql_debug.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "className": "QPSQLDriverPlugin", "debug": true, "version": 330498 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "/Users/yukie/build-testsqlite-Desktop_Qt_5_11_2_clang_64bit-Release/sqldrivers" ... Cannot load library /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib Referenced from: /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib Reason: image not found) QLibraryPrivate::loadPlugin failed on "/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n Referenced from: /Volumes/Potato/apps/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n Reason: image not found)" QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 QSqlError("", "Driver not loaded", "Driver not loaded") QSqlQuery::prepare: database not open QSqlQuery::prepare: database not open QSqlQuery::prepare: database not open
-
I didn't realise that you are working on macOS. This thread is for Windows.
As for your issue, it has already been answered many times already on this forum. Please search it.
-
@jsulm I had the same issue as @lucaynnofrota where the qtsqldrivers-config.pri file was not found. Any idea where I can find the file?
-
@ankurboruah This file is created when you configure Qt.
-
Which version of Qt are you trying to build the driver for ?
-
The problem with MySQL I could not solve.
I tried using Postgres and I had no problem. Shortly afterwards I realized that I was making a Mistake, the latest versions of MySQL are for 64bit and the version I was using from 32bit qt