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
    Had similar issue on Qt 5.9.4. It is simple to compile it, steps to do it:

    1. Go to /opt/Qt/5.9.4/Src/qtbase/src and use qmake
    2. Go to /opt/Qt/5.9.4/Src/qtbase/src/plugins and use qmake
    3. Go to /opt/Qt/5.9.4/Src/qtbase/src/plugins/sqldrivers and use qmake
    4. Go to /opt/Qt/5.9.4/Src/qtbase/src/plugins/sqldrivers/mysql and use qmake, make and make install

    This should work. Of course go to wanted Qt version not 5.9.4 and use proper qmake.



  • @kolegs Tried the exact same steps you mentioned but getting the same error

    qsql_mysql.cpp:235:9: error: ‘my_bool’ does not name a type; did you mean ‘_Bool’?
    
    

    Please note that all mysql related packages are installed already.

    
    dnf install mysql*
    Package mysql++-3.2.3-2.fc27.x86_64 is already installed, skipping.
    Package mysql++-devel-3.2.3-2.fc27.x86_64 is already installed, skipping.
    Package mysql++-manuals-3.2.3-2.fc27.x86_64 is already installed, skipping.
    Package mysql-community-client-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-common-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-devel-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-libs-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-server-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-test-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-java-1:5.1.38-5.fc27.noarch is already installed, skipping.
    Package mysql-connector-net-6.9.9-5.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-net-devel-6.9.9-5.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-5.3.9-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-debuginfo-5.3.10-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-debugsource-5.3.10-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-setup-5.3.9-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-setup-debuginfo-5.3.10-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-odbc-test-5.3.9-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-python-2.1.7-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-python-cext-2.1.7-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-python-debuginfo-2.1.7-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-python3-2.1.7-1.fc27.x86_64 is already installed, skipping.
    Package mysql-connector-python3-cext-2.1.7-1.fc27.x86_64 is already installed, skipping.
    Package mysql-mmm-2.2.1-17.fc27.noarch is already installed, skipping.
    Package mysql-mmm-agent-2.2.1-17.fc27.noarch is already installed, skipping.
    Package mysql-mmm-monitor-2.2.1-17.fc27.noarch is already installed, skipping.
    Package mysql-mmm-tools-2.2.1-17.fc27.noarch is already installed, skipping.
    Package mysql-ref-manual-5.7-en-html-chapter-1-20171228.noarch is already installed, skipping.
    Package mysql-ref-manual-5.7-en-pdf-1-20171228.noarch is already installed, skipping.
    Package mysql-router-2.1.5-1.fc27.x86_64 is already installed, skipping.
    Package mysql-router-debuginfo-2.1.5-1.fc27.x86_64 is already installed, skipping.
    Package mysql-shell-1.0.11-1.fc27.x86_64 is already installed, skipping.
    Package mysql-shell-debuginfo-1.0.11-1.fc27.x86_64 is already installed, skipping.
    Package mysql-utilities-1.6.5-1.fc27.noarch is already installed, skipping.
    Package mysql-workbench-community-6.3.10-1.fc27.x86_64 is already installed, skipping.
    Package mysql-workbench-community-debuginfo-6.3.10-1.fc27.x86_64 is already installed, skipping.
    Package mysql57-community-release-fc27-10.noarch is already installed, skipping.
    Package mysqlreport-3.5-17.fc27.noarch is already installed, skipping.
    Package mysqltuner-1.6.18-3.git.401cb54.fc27.noarch is already installed, skipping.
    Dependencies resolved.
    Nothing to do.
    Complete!
    
    

    This already shows that necessary packages are installed

    
    Package mysql-community-client-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-common-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-devel-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-libs-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-server-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    Package mysql-community-test-8.0.4-0.1.rc.fc27.x86_64 is already installed, skipping.
    
    
    

    So why does it keep complaining the same. Specifically my_bool does not name a type in qsql_mysql.cpp:235:9



  • @kolegs I even tried to run qmake from the parent directories but facing the same error. Also interestingly other than Database stuffs everything else is working fine with the latest update. So kinda stuck here with this. Don't know how to solve this.

    This is also a fresh install so no other versions of Qt is there in the machine. Of course i'm using KDE so it has its own Qt libraries but that shouldn't interfere with this. Or atleast i've never seen it interfere. Everything used to work in perfect harmony with the previous version 5.8 which makes the situation even more strange as newer versions should provide smoother experience overall.



  • Please does anyone know how to solve this ? Its been over 5 days now. Stuck in the same place. I'm not even sure is this any dependency issue because all the necessary libraries are installed and double checked. Why does this error keeps popping up ?

    Searched everywhere in Google but no solution !!


  • Moderators

    @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.


  • Moderators

    @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
    
    

  • Lifetime Qt Champion

    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"
    

  • Lifetime Qt Champion

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.