Qt 5.10.0 MySQL drivers fails to compile
-
Hi , I've recently updated my machine to the latest version of Fedora Linux 27 and Qt 5.10.0. The Qt framework was installed using the Offline installer qt-opensource-linux-x64-5.10.0 which I usually do. All of the options were checked during installation to ensure that all the plugins , sources, and libraries are installed. Again this is how i usually do a Fresh Install of Qt after an Update.
Now the problem is that MySQL driver is not loaded
QSqlDatabase: QMYSQL driver not loaded
Previously on the earlier versions like Qt 5.8 or 5.7 etc this problem was solved either by linking the correct version of libmysqlclient.so or recompiling it from the Src directory. But this is not working now at all.
So here is the ldd of the Qt program which needs MySQL
linux-vdso.so.1 (0x00007ffc13709000) libmysqlclient.so.21 => /usr/lib64/mysql/libmysqlclient.so.21 (0x00007f59732cb000) libzmq.so.5 => /usr/local/lib/libzmq.so.5 (0x00007f5973045000) libQt5WebEngineWidgets.so.5 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5WebEngineWidgets.so.5 (0x00007f5972e04000) libQt5PrintSupport.so.5 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5PrintSupport.so.5 (0x00007f5972b97000) libQt5Widgets.so.5 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Widgets.so.5 (0x00007f597235e000)
As can be seen this needs the latest version of mysql libmysqlclient.so.21 library which is already installed
This is the ldd output of /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
linux-vdso.so.1 (0x00007ffeb8bf8000) libQt5Sql.so.5 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f60cd408000) libQt5Core.so.5 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f60cccba000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f60cca9b000) libmysqlclient.so.18 => not found libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f60cc715000) libm.so.6 => /lib64/libm.so.6 (0x00007f60cc3c0000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f60cc1a9000) libc.so.6 => /lib64/libc.so.6 (0x00007f60cbdc6000) libz.so.1 => /lib64/libz.so.1 (0x00007f60cbbaf000) libicui18n.so.56 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f60cb716000) libicuuc.so.56 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f60cb35e000) libicudata.so.56 => /opt/Qt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f60c997b000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f60c9777000) libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f60c9575000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f60c9261000) /lib64/ld-linux-x86-64.so.2 (0x00007f60cd863000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f60c8fee000)
Clearly this says libmysqlclient.so.18 => not found as because the latest version libmysqlclient.so.21 is installed.
Now when i try to recompile the drivers i'm faced with a repeated problem
qsql_mysql.cpp:235:9: error: ‘my_bool’ does not name a type; did you mean ‘_Bool’?
Here is what i did
cd /opt/Qt/Qt5.10.0/5.10.0/Src/qtbase/src/plugins/sqldrivers/mysql /opt/Qt/Qt5.10.0/5.10.0/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql" mysql.pro make
Make is failing with a strange error
g++ -c -pipe -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -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/mysql -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtSql/5.10.0 -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtSql/5.10.0/QtSql -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtCore/5.10.0 -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtCore/5.10.0/QtCore -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtSql -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/include/QtCore -I.moc -isystem /usr/include/mysql -I/opt/Qt/Qt5.10.0/5.10.0/gcc_64/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp qsql_mysql.cpp:235:9: error: ‘my_bool’ does not name a type; did you mean ‘_Bool’? my_bool nullIndicator; ^~~~~~~ _Bool qsql_mysql.cpp: In constructor ‘QMYSQLResultPrivate::QMyField::QMyField()’: qsql_mysql.cpp:231:28: error: class ‘QMYSQLResultPrivate::QMyField’ does not have any field named ‘nullIndicator’ : outField(0), nullIndicator(false), bufLength(0ul), ^~~~~~~~~~~~~ qsql_mysql.cpp: In member function ‘bool QMYSQLResultPrivate::bindInValues()’: qsql_mysql.cpp:430:28: error: ‘struct QMYSQLResultPrivate::QMyField’ has no member named ‘nullIndicator’ bind->is_null = &f.nullIndicator; ^~~~~~~~~~~~~ qsql_mysql.cpp: In member function ‘virtual QVariant QMYSQLResult::data(int)’: qsql_mysql.cpp:641:15: error: ‘const struct QMYSQLResultPrivate::QMyField’ has no member named ‘nullIndicator’ if (f.nullIndicator) ^~~~~~~~~~~~~ qsql_mysql.cpp: In member function ‘virtual bool QMYSQLResult::isNull(int)’: qsql_mysql.cpp:734:35: error: ‘const struct QMYSQLResultPrivate::QMyField’ has no member named ‘nullIndicator’ return d->fields.at(field).nullIndicator; ^~~~~~~~~~~~~ qsql_mysql.cpp: In member function ‘virtual bool QMYSQLResult::exec()’: qsql_mysql.cpp:987:13: error: ‘my_bool’ was not declared in this scope QVector<my_bool> nullVector; ^~~~~~~ qsql_mysql.cpp:987:13: note: suggested alternative: ‘_Bool’ QVector<my_bool> nullVector; ^~~~~~~ _Bool qsql_mysql.cpp:987:20: error: template argument 1 is invalid QVector<my_bool> nullVector; ^ qsql_mysql.cpp:1001:20: error: request for member ‘resize’ in ‘nullVector’, which is of non-class type ‘int’ nullVector.resize(values.count()); ^~~~~~ qsql_mysql.cpp:1008:25: error: invalid types ‘int[int]’ for array subscript nullVector[i] = static_cast<my_bool>(val.isNull()); ^ qsql_mysql.cpp:1008:41: error: ‘my_bool’ does not name a type; did you mean ‘_Bool’? nullVector[i] = static_cast<my_bool>(val.isNull()); ^~~~~~~ _Bool qsql_mysql.cpp:1009:46: error: invalid types ‘int[int]’ for array subscript currBind->is_null = &nullVector[i]; ^ qsql_mysql.cpp:1105:17: error: expected ‘;’ before ‘update_max_length’ my_bool update_max_length = true; ^~~~~~~~~~~~~~~~~ qsql_mysql.cpp:1114:72: error: ‘update_max_length’ was not declared in this scope mysql_stmt_attr_set(d->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &update_max_length); ^~~~~~~~~~~~~~~~~ qsql_mysql.cpp: In member function ‘virtual bool QMYSQLDriver::open(const QString&, const QString&, const QString&, const QString&, int, const QString&)’: qsql_mysql.cpp:1316:5: error: ‘my_bool’ was not declared in this scope my_bool reconnect=false; ^~~~~~~ qsql_mysql.cpp:1316:5: note: suggested alternative: ‘_Bool’ my_bool reconnect=false; ^~~~~~~ _Bool qsql_mysql.cpp:1334:21: error: ‘reconnect’ was not declared in this scope reconnect = true; ^~~~~~~~~ qsql_mysql.cpp:1334:21: note: suggested alternative: ‘connect’ reconnect = true; ^~~~~~~~~ connect qsql_mysql.cpp:1415:13: error: ‘reconnect’ was not declared in this scope if (reconnect) ^~~~~~~~~ qsql_mysql.cpp:1415:13: note: suggested alternative: ‘connect’ if (reconnect) ^~~~~~~~~ connect make: *** [Makefile:802: .obj/qsql_mysql.o] Error 1
Seriously i've been using Qt for some years now and never before did i faced this problem when setting up the MySQL drivers. And whats odd is that now the machine is updated with all the latest versions.
Please let me know how can i solve this. Have been trying to get it working for the last 3 days without any progress. And without Qt nothing runs on my work environment. All of the program is fuelled by Qt and C++ with MySQL as the only database. Its like a sudden holiday in workplace lol... Due to some version mismatch
@Maxx-Dovahkiin said in Qt 5.10.0 MySQL drivers fails to compile:
/opt/Qt/Qt5.10.0/5.10.0/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql" mysql.pro
I'm not sure it is necessary to pass the include/libs path to qmake as both headers and libs are in system directories (/usr/include, usr/lib64).
-
@Maxx-Dovahkiin said in Qt 5.10.0 MySQL drivers fails to compile:
/opt/Qt/Qt5.10.0/5.10.0/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql" mysql.pro
I'm not sure it is necessary to pass the include/libs path to qmake as both headers and libs are in system directories (/usr/include, usr/lib64).
@jsulm Well actually i tried both ways with the path and without but still ended in the same place.
qsql_mysql.cpp:235:9: error: ‘my_bool’ does not name a type; did you mean ‘_Bool’?
Don't know if this is some dependency issue or what... I even tried to change the c++ standard to C++11 in Makefile but didn't helped.
-
Seriously this is getting very very weird. Searching all over the internet like a madman for days now and nowhere does this error comes up and i have literally no clue as to what needs to be done. Whether am i missing very specific packages or done something wrong ?
Literally tried all solutions out there still ending up in the same error.
-
Seriously this is getting very very weird. Searching all over the internet like a madman for days now and nowhere does this error comes up and i have literally no clue as to what needs to be done. Whether am i missing very specific packages or done something wrong ?
Literally tried all solutions out there still ending up in the same error.
@Maxx-Dovahkiin Can't you simply create libmysqlclient.so.18 symlink pointing to libmysqlclient.so.21?
-
@Maxx-Dovahkiin Can't you simply create libmysqlclient.so.18 symlink pointing to libmysqlclient.so.21?
@jsulm Yes did that many a times but somehow that didn't worked...
ln -s libmysqlclient.so.21.0.4 libmysqlclient.so.18
But Qt doesn't seem to agree...
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Database Cannot Be Opened
-
Hi,
Run your application with the
QT_DEBUG_PLUGINS
environment variable set to one to see what happens with the MySQL plugin. -
Hi,
Run your application with the
QT_DEBUG_PLUGINS
environment variable set to one to see what happens with the MySQL plugin.@SGaist said in Qt 5.10.0 MySQL drivers fails to compile:
QT_DEBUG_PLUGINS
Ok i have set QT_DEBUG_PLUGINS in Run Environment to 1. Now the error is a bit different.
An error occurred while opening the connection: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory QMYSQL: Unable to connect
Application output pane shows this
QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" Found metadata in lib /opt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QMYSQL3", "QMYSQL" ] }, "className": "QMYSQLDriverPlugin", "debug": false, "version": 330240 } Got keys from plugin meta data ("QMYSQL3", "QMYSQL") QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlpsql.so" Found metadata in lib /opt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlpsql.so, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL7", "QPSQL" ] }, "className": "QPSQLDriverPlugin", "debug": false, "version": 330240 } Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "/var/local/Reader/build-Reader-Desktop_Qt_5_10_0_GCC_64bit-Debug/sqldrivers" ... loaded library "/opt/Qt5.10.0/5.10.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" Database Cannot Be Opened loaded library "/opt/Qt5.10.0/5.10.0/gcc_64/plugins/iconengines/libqsvgicon.so"
-
Did you check that you have that
caching_sha2_password.so
library ? -
So finally the solution have been found. I had to do a Fresh Install of Fedora 27 and this time installed the previous MySQL version which was there in Fedora 25
dnf install https://dev.mysql.com/get/mysql57-community-release-fc25-9.noarch.rpm dnf install mysql-community-server
Also installed all other dependencies. After that installed Qt 5.10.0 from the offline package as usual. Then recompiled the sqldrivers and it just went smoothly without showing any errors at all.
So i guess MySQL 8.0 is incompatible with Qt as of now.
-
You have to set MySQL Server to use legacy authentication (during the installation or just reconfigure it later). You have to do so even for MySQL Workbench to work.
Edit: the solution doesn't work after all... sorry. So I'm now with the same problem - my Qt app doesn't work with MySQL at all... maybe the legacy libmysql.dll is needed?
Edit 2: a workaround I've used is to use ODBC driver to connect to MySQL database.