Error while compiling Qt mySQL driver



  • Hello guys,

    Im getting this error while trying to connect to a database in my Qt project:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

    libqsqlmysql.so it is located in my sqldrivers, mysql client and server are installed on my machine Im using Ubuntu 17 and Qt 5.9.

    When I tried ldd libqsqlmysql.so I get this: libmysqlclient.so.18 => not found, so I tried to compile a new one from qtbase(source code) but when I run:

    qmake "INCLUDEPATH+=MYSQL INCLUDE LOCATION" "LIBS+=-L MYSQL LIB LOCATION" mysql.pro a Makefile is created but I get this error too:

    Cannot read /home/[My Username]/Desktop/qtbase-dev/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory

    When I enter make, I get this error:
    /usr/bin/ld: cannot find /usr/lib/mysql: File format not recognized
    collect2: error: ld returned 1 exit status
    Makefile:73: recipe for target '../plugins/sqldrivers/libqsqlmysql.so' failed
    make: *** [../plugins/sqldrivers/libqsqlmysql.so] Error 1

    So this seems pretty annoying, any help is welcome :)


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What version of MySQL did you install ? Are you building or cross-compiling ?



  • MySQL version: 5.7.18
    What Im trying to do is to build a newer version of libqsqlmysql because with the older one I get the above mentioned error: QSqlDatabase: QMYSQL driver not loaded, from reading a lot of threads I saw that you need to build it yourself to fit your mySql version.



  • I solved the problem with installing libmysqlclient18 package.



  • Same issue here.
    How did you install libmysqlclient18 ?





  • Hi guys,

    I've same issue although I already installed libmysqlclient20 and libmysqlclient-dev and run:
    sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so as mentioned here:

    May I get some help here.

    Thanks in advance.

    I'm using:

    • Qt 5.9.1
    • MySQL 5.7.18
    • Linux Mint 18.2 x64 xfce (Ubuntu 16.04)

    log

    $ /home/mogla/.Qt/5.9.1/gcc_64/bin/qmake
    Cannot read /home/mogla/.Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
    $ ls /home/mogla/.Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/
    configure.json	configure.pri  db2  ibase  lib	mkspecs  mysql	oci  odbc  plugins  psql  qsqldriverbase.pri  README  sqldrivers.pro  sqlite  sqlite2  tds
    $ 
    

    IMPORTANT:
    This issue occurs with Qt 5.9.1 while doesn't with Qt 5.8!


  • Lifetime Qt Champion

    Hi,

    Looks like it's a generated file however I don't know yet exactly how it is generated.

    In between, you can try to use that one:

    QT.sqldrivers.enabled_features =
    QT.sqldrivers.disabled_features =
    QT.sqldrivers.QT_CONFIG =
    QT.sqldrivers.exports =
    QT.sqldrivers_private.enabled_features = sql-sqlite sql-mysql
    QT.sqldrivers_private.disabled_features = sql-db2 sql-ibase sql-oci sql-odbc sql-psql sql-sqlite2 sql-tds system-sqlite
    QT.sqldrivers_private.libraries =
    

    It's based on one of my builds.



  • @SGaist said in Error while compiling Qt mySQL driver:

    Hi,

    Looks like it's a generated file however I don't know yet exactly how it is generated.

    In between, you can try to use that one:

    QT.sqldrivers.enabled_features =
    QT.sqldrivers.disabled_features =
    QT.sqldrivers.QT_CONFIG =
    QT.sqldrivers.exports =
    QT.sqldrivers_private.enabled_features = sql-sqlite sql-mysql
    QT.sqldrivers_private.disabled_features = sql-db2 sql-ibase sql-oci sql-odbc sql-psql sql-sqlite2 sql-tds system-sqlite
    QT.sqldrivers_private.libraries =
    

    It's based on one of my builds.

    Where can I use these configs?!


  • Lifetime Qt Champion

    That's the content of the generated qtsqldrivers-config.pri I have.



  • @SGaist said in Error while compiling Qt mySQL driver:

    Hi,

    Looks like it's a generated file however I don't know yet exactly how it is generated.

    In between, you can try to use that one:

    QT.sqldrivers.enabled_features =
    QT.sqldrivers.disabled_features =
    QT.sqldrivers.QT_CONFIG =
    QT.sqldrivers.exports =
    QT.sqldrivers_private.enabled_features = sql-sqlite sql-mysql
    QT.sqldrivers_private.disabled_features = sql-db2 sql-ibase sql-oci sql-odbc sql-psql sql-sqlite2 sql-tds system-sqlite
    QT.sqldrivers_private.libraries =
    

    It's based on one of my builds.

    I created a new file depending on yours. qmake done fine while make gave me this error:

    $ make
    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. -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtSql/5.9.1 -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtSql/5.9.1/QtSql -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtCore/5.9.1 -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtCore/5.9.1/QtCore -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtSql -I/home/mbnoimi/.Qt/5.9.1/gcc_64/include/QtCore -I.moc -I/home/mbnoimi/.Qt/5.9.1/gcc_64/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
    In file included from qsql_mysql.cpp:40:0:
    qsql_mysql_p.h:60:19: fatal error: mysql.h: No such file or directory
    compilation terminated.
    Makefile:773: recipe for target '.obj/qsql_mysql.o' failed
    make: *** [.obj/qsql_mysql.o] Error 1
    $
    


  • I wonder, does this issue is a new bug in Qt 5.9.1 because as I said before "Qt 5.8 works fine"


  • Lifetime Qt Champion

    The build system has changed so it looks rather like a documentation bug.



  • Qt plugins really pain in the ass... I'm very frustrated!!!

    It seems I've to rollback to Microsoft products after years of using Qt. Because of this stupid policy of Qt I always spend hours and hours on deployment or building a stupid plugin which suppose to be available in the binary distro!!!

    Why the developer needs to rebuild anything from source code if he/she chose to use binary distro of Qt!!!

    Any way, I filed a bug report about this stupid bug in this link:
    https://bugreports.qt.io/browse/QTBUG-62078

    For whom concern:
    https://forum.qt.io/topic/81272/licenses-craziness



  • Have you qMake it?




Log in to reply
 

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