I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4
-
Start your application with the
QT_DEBUG_PLUGINS
environment variable set to 1.You'll see what is happening with your plugin.
-
@surendar-dharani Your OS seems to have mysql, so, better install them.
If you didn't compile the mysql driver, you could guide you with:
https://fecub.wordpress.com/2014/08/12/compilecreate-mysql-driver-for-qt5-on-windows/When you build an app that's use mysql driver, and the plugin is compiled, and there's no mysql library availible in your system, you have the error:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
notice that QMYSQL is availible but not loaded, means that the plugin is compiled but the library was not found it.
so, having been installed mysql-server and mysql-client from your package manager, find the library libmysqlclient.so.18, in a terminal you could use as super user:
find / -name libmysqlclient.so.18
paste here the results to check it out
-
Surendar Dharanireplied to RonaldViscarraL on 6 Sept 2019, 13:08 last edited by Surendar Dharani 9 Jun 2019, 13:14
@ronaldviscarral @SGaist Hi have installed in my other system from the scratch itself, Now i got this.
When i ran this sh configure -sql-mysql
Output:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. yes
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... noAnd i tried to run QT 5.13.1
And I got this ,
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7And I checked in /opt/Qt/5.13.1/gcc_64/plugins/sqldrivers/
But libqsqlmysql.so file is not found in this location.
i think little thing is missing here. Please guide me. Thanks in advance.
-
Hi @Surendar-Dharani ,
you have to install QMYSQL plugin first.
I met this issue before and have 2 topics that you can refer
https://forum.qt.io/topic/106421/qt-mac-version-doesn-t-have-file-libqsqlmysql-dylib
https://forum.qt.io/topic/106565/mysql-qt-create-plugin-mysql-for-qt-on-mac -
Surendar Dharanireplied to Quang Phu on 7 Sept 2019, 10:42 last edited by Surendar Dharani 9 Jul 2019, 11:03
@quang-phu @SGaist @RonaldViscarraL
when i run this /opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers# make sub-mysql
I got this :
cd mysql/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro MYSQL_PREFIX=/usr/local ) && make -f Makefile
make[1]: Entering directory '/opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql'
g++ -c -g -O2 -fdebug-prefix-map=/build/qtbase-opensource-src-5DihdB/qtbase-opensource-src-5.9.5+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/mysql -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
In file included from /usr/include/x86_64-linux-gnu/qt5/QtSql/qtsqlglobal.h:43:0,
from /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqldriver.h:43,
from qsql_mysql_p.h:54,
from qsql_mysql.cpp:40:
qsql_mysql.cpp:1469:5: error: division by zero in #if
#if QT_CONFIG(thread)
^
qsql_mysql.cpp:1483:5: error: division by zero in #if
#if QT_CONFIG(thread)
^
qsql_mysql.cpp: In function ‘QSqlField qToField(MYSQL_FIELD, QTextCodec)’:
qsql_mysql.cpp:344:44: error: no matching function for call to ‘QSqlField::QSqlField(QString, QVariant::Type, QString)’
toUnicode(tc, field->table));
^
In file included from qsql_mysql.cpp:46:0:
/usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:60:5: note: candidate: QSqlField::QSqlField(const QSqlField&)
QSqlField(const QSqlField& other);
^~~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:60:5: note: candidate expects 1 argument, 3 provided
/usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:57:14: note: candidate: QSqlField::QSqlField(const QString&, QVariant::Type)
explicit QSqlField(const QString& fieldName = QString(),
^~~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:57:14: note: candidate expects 2 arguments, 3 provided
Makefile:376: recipe for target '.obj/qsql_mysql.o' failed
make[1]: [.obj/qsql_mysql.o] Error 1
make[1]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql'
Makefile:42: recipe for target 'sub-mysql' failed
make: [sub-mysql] Error 2**and when i ran sh configure in qtbase folder i got this,
g++: error: /opt/Qt/5.13.1/Src/qtbase/lib/libqtpcre2.a: No such file or directory
Makefile:1214: recipe for target '../../lib/libQt5Core.so.5.13.1' failed
make[2]: *** [../../lib/libQt5Core.so.5.13.1] Error 1
make[2]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src/corelib'
Makefile:213: recipe for target 'sub-corelib-install_subtargets' failed
make[1]: *** [sub-corelib-install_subtargets] Error 2
make[1]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src'
Makefile:62: recipe for target 'sub-src-install_subtargets' failed
make: *** [sub-src-install_subtargets] Error 2 -
From the looks of it, you are mixing several versions of Qt.
There's references to both Qt 5.13 and Qt 5.9.5 which is not a good sign. -
@sgaist hi,
How to do it for version 5.13.1
Because i got confused. Now what I have to do?
Uninstall 5.9 version and try qmakr for 5.13.1 version?
-
Hi,
I got output.
In terminal,
I just ran
sh configure -sql-mysql
after that ranmake
after that ranmake install
Thanks for your valuable support and valuable time.
Post 21 of 29