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

How to create the plugin of MARIADB for Qt5



  • Hi,
    My installation is:
    Win 7
    QT5.10.1
    MariaDB 10.2.14

    I tray to compile driver with this step:

    set mysql=C:\\PROGRA~2\\MARIAD~1.2
    cd C:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers
    qmake sqldrivers.pro
    cd C:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers\mysql\
    qmake "INCLUDEPATH+=%mysql%\\include\\mysql\\server" "LIBS+=%mysql%\\lib\\libmariadb.lib" -o Makefile mysql.pro
    

    I get the message:
    Project ERROR: Library 'mysql' is not defined.

    In the path C:\PROGRA~2\MARIAD~1.2\LIB
    I have the following files:
    libmariadb.dll
    libmariadb.lib
    libmariadb.pbd
    mariadbclient.lib
    mysqlservices.lib

    I do not understand where I'm wrong considering that the same procedure works with MYSQL.
    la sola differenza è che con MYSQL ho la libreria libmysql.lib mentre con MARIADB ho libmariadb.lib



  • qmake -- MYSQL_INCDIR=C:\PROGRA~2\MARIAD~1.2\include\mysql "MYSQL_LIBDIR=C:\PROGRA~2\MARIAD~1.2\lib" MYSQL_LIBS="-llibmariadb"

    OK this work.
    Thank you for your dedicated time.

    blackout69


  • Lifetime Qt Champion

    Hi,

    The instructions for building plugins have change since some times. See here.



  • Thank you SGaist for your replay,
    but my installation of MariaDB I do not have an opt folder.

    qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
    

    The syntax of this command is not clear. Maybe it's only for Mysql. I want to use MariaDB.
    Do you have any link describing the procedure for MariaDB?

    Thank you in advance.
    blackout69


  • Qt Champions 2019

    @blackout69 said in How to create the plugin of MARIADB for Qt5:

    I do not have an opt folder

    then replace it with the folder in which you have MariaDB libs...



  • Thank you jsulm,
    I've run the following command:

    cd C:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers\mysql\
    qmake -- MYSQL_INCDIR=C:\\PROGRA~2\\MARIAD~1.2\\include "MYSQL_LIBDIR=C:\\PROGRA~2\\MARIAD~1.2\\lib"
    

    I get this output

    Running configuration tests...
    Done running configuration tests.

    Configure summary:

    Qt Sql:
    DB2 (IBM) .............................. no
    InterBase .............................. no
    MySql .................................. no
    OCI (Oracle) ........................... no
    ODBC ................................... yes
    PostgreSQL ............................. no
    SQLite2 ................................ no
    SQLite ................................. yes
    Using system provided SQLite ......... no
    TDS (Sybase) ........................... no

    Qt is now configured for building. Just run 'mingw32-make'.
    Once everything is built, Qt is installed.
    You should NOT run 'mingw32-make install'.
    Note that this build cannot be deployed to other machines or devices.

    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.

    mingw32-make
    

    The drivers have been compiled for sqlite and odbc.
    I want to compile the driver for mariadb.
    How can I enable mariadb driver compilation.

    Thanks in advance
    blackout69


  • Lifetime Qt Champion

    You should check the content of the tests to see what failed for MySQL.



  • Hi all,

    I checked the tests, but the config.tests folder is automatically generated when I run the qmake command. It is not clear who decides and with which criteria which drivers to enable and which do not. Consider that I also installed MariaDB Connector, but it does not change anything.
    One thing I noticed instead is with the latest version of MariaDB, in the lib folder, there is no libmysql library but I find libmariadb.
    Perhaps the script that manages the enabling of the drivers, search for libmysql and not finding it does not enable mysql?

    Thanks in advance


  • Lifetime Qt Champion

    Hence my question about the content of the folder after it has been created.



  • Hi SGaist,
    config.tests.zip

    My config.tests folder.
    blackout69


  • Lifetime Qt Champion

    What do you get if you call make in the mysql subfolder ?



  • C:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql>mingw32-make
    g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\utils\my_sql\my_sql\include -IC:\utils\postgresql\pgsql\include -IC:\openssl\include -IC:\PROGRA~2\MARIAD~1.2\include -IC:\Qt\5.10.1\mingw53_32\mkspecs\win32-g++  -o main.o main.cpp
    main.cpp:5:19: fatal error: mysql.h: No such file or directory
    compilation terminated.
    Makefile:439: recipe for target 'main.o' failed
    mingw32-make: *** [main.o] Error 1
    

  • Lifetime Qt Champion

    Where exactly do you have that file in your system ?



  • C:\Program Files (x86)\MariaDB 10.2\include\mysql
    C:\Program Files (x86)\MariaDB 10.2\include\mysql\server


  • Lifetime Qt Champion

    Then you are missing the mysql folder in the path given to MYSQL_INCDIR



  • qmake -- MYSQL_INCDIR=C:\PROGRA~2\MARIAD~1.2\include\mysql "MYSQL_LIBDIR=C:\PROGRA~2\MARIAD~1.2\lib"

    Configure summary:

    Qt Sql:
    DB2 (IBM) .............................. no
    InterBase .............................. no
    MySql .................................. no
    OCI (Oracle) ........................... no
    ODBC ................................... yes
    PostgreSQL ............................. no
    SQLite2 ................................ no
    SQLite ................................. yes
    Using system provided SQLite ......... no
    TDS (Sybase) ........................... no


  • Lifetime Qt Champion

    Again, check what happens if you try to build the MySQL test application.



  • C:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql>mingw32-make
    g++ -Wl,-s -Wl,-subsystem,console -mthreads -o mysql.exe main.o -LC:\utils\my_sql\my_sql\lib -LC:\utils\postgresql\pgsql\lib -LC:\PROGRA~2\MARIAD~1.2\lib -llibmysql
    C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibmysql
    collect2.exe: error: ld returned 1 exit status
    Makefile:64: recipe for target 'mysql.exe' failed
    mingw32-make: *** [mysql.exe] Error 1

    My lib folder is:
    C:\Program Files (x86)\MariaDB 10.2\lib
    libmariadb.dll
    libmariadb.lib
    libmariadb.pdb
    mariadbclient.lib
    mysqlservices.lib


  • Lifetime Qt Champion

    Try setting MYSQL_LIBS to -lmariadb in addition to the other variables you already set.



  • qmake -- MYSQL_INCDIR=C:\PROGRA~2\MARIAD~1.2\include\mysql "MYSQL_LIBDIR=C:\PROGRA~2\MARIAD~1.2\lib" MYSQL_LIBS="-llibmariadb"

    OK this work.
    Thank you for your dedicated time.

    blackout69



  • @blackout69

    I follow your step to build static mysql but got fail

    0: set mysql=c:\mysql
    1: cd C:\Qt\Qt5.12.0\5.12.0\Src\qtbase\src\plugins\sqldrivers
    2: qmake sqldrivers.pro
    3: cd C:\Qt\Qt5.12.0\5.12.0\Src\qtbase\src\plugins\sqldrivers\mysql
    4: qmake -- MYSQL_INCDIR=C:\mysql\include "MYSQL_LIBDIR=C:\mysql\lib" MYSQL_LIBS="-lmariadbclient"
    got error after this step
    Project ERROR: Library 'mysql' is not defined.
    5: cd C:\Qt\Qt5.12.0\5.12.0\Src\qtbase\src\plugins\sqldrivers
    6: qmake -- MYSQL_INCDIR=C:\mysql\include "MYSQL_LIBDIR=C:\mysql\lib" MYSQL_LIBS="-lmariadbclient"
    no error after this step
    7: nmake sub-mysql
    got error after this step
    NMAKE : fatal error U1073: 不知道如何生成“sub-mysql” Stop.
    ( NMAKE : fatal error U1073: don't know how to generate “sub-mysql” Stop.)

    could you help me to correct the steps?
    I don't know which step or path is wrong.
    Many thanks .


Log in to reply