Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMYSQL DRIVER NOT LOADED



  • Hi All,

    I'm trying to make a program that inserts a record into a database. I have lost 2 days for error.I can't connect to the database. i get the following error:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL3 QODBC !
    I understand I have to buid mysql driver with mysql.h and ilbmysql.dll supply by MYSQL

    I'm trying with MinGW 7.3.0 32 bit command:
    cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers
    qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
    this error:
    qt1.PNG

    and other:
    cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" "LIBS+=C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.lib" mysql.pro

    this error:
    qt2.PNG

    I read the Error on github and then I config I delete QMAKE_USE+= mysql in mysql.pro
    qt3.PNG

    And ther command:
    qt4.PNG

    I can't build file qsqlmysql.dll for driver !! Please help me . If you buid driver for QT 5.14.1 sucsses , can you send me qsqlmysql.dll file ! Thanks best for your time !!!!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are missing a double quote in the LIBS part of your qmake call.



  • @SGaist said in QMYSQL DRIVER NOT LOADED:

    Hi and welcome to devnet,
    You are missing a double quote in the LIBS part of your qmake call.

    Thanks for reply I see you solved this problem in other topic but What i was wrong :((
    qt5.PNG


  • Lifetime Qt Champion

    @nguyendinh said in QMYSQL DRIVER NOT LOADED:

    What i was wrong

    It would be nice if you would put text instead of screen-shots!
    What you are doing wrong: you need to put paths containing spaces into "". If you take time to take a closer look at your screen- shot you will see what is wrong: the path to include directory contains spaces, but you did not put it into "", so you have stuff like:

    -IC:\Program -IFiles
    

    which is of course wrong.



  • @jsulm
    Thanks for your support
    This my command in QT 5.14.1 mingW 7.3.0 32bit
    (I use MYSQL 8.0 64 bit)

    This my command:
    1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
    2.qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

    And then this equal:
    q1.PNG


  • Lifetime Qt Champion

    @nguyendinh said in QMYSQL DRIVER NOT LOADED:

    qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

    qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
    


  • @jsulm Thanks you but the same as
    1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
    2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
    3.mingw32-make

    q2.PNG


  • Lifetime Qt Champion

    @nguyendinh Your screen-shot still shows your wrong qmake call...
    Please do it like I suggested.



  • @jsulm sorry I upload wrong images
    i copied your command but the equal same as:
    1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
    2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"mysql.pro
    3.mingw32-make

    Thanks best for your time!!!
    q4.PNG


  • Lifetime Qt Champion

    @nguyendinh Please make sure you call qmake/make from a clean state. Means: remove all build artefacts first. Better do out of source build (not from source code directory).



  • @jsulm Thanks every body In this day , I solved the problem. All problem in Makefile
    Makefile buid qsqlmysql.dll driver but the linked LIBS or INCLUDEPATH wrong because you using more than 1 qmake command . And this solved you put the true link in Makefile
    (Makefile in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers)
    q1.PNG

    You can fix Makefile in with notepad or etc and then save file
    then again in QT command run: mingw32-make

    and then qsqlmysql build in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
    then you have to coppy this file for C:\Qt\Qt5.14.1\5.14.1\mingw73_32\plugins\sqldrivers

    Now we can connect to mysql workbench Thanks for all.





  • @lincoln Capture.PNG

    Open Makefile with notepad or IDE C++ , config and then save file.


Log in to reply