Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qtcreator 32bit and mysql 8.0 64bit
Forum Updated to NodeBB v4.3 + New Features

Qtcreator 32bit and mysql 8.0 64bit

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
qmysql
11 Posts 3 Posters 2.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raftapss
    wrote on last edited by
    #1

    Hello everyone ,
    I am a novice in development Qt. I have to download the opensource version of Qt to train on this framework that I find complete and pretty!
    I made myself a small database of 3 tables to train the relationship N to M. The only problem is that I can not load the MYSQL driver. I refer to Qt's documentation here
    https://doc.qt.io/qt-5/sql-driver.html
    It is put that it is necessary to compile the drivers because there are problems of compatibility of license.

    According to the documentation, I have to make this command

    cd $QTDIR/qtbase/src/plugins/sqldrivers
    

    Except this command does not work because the path does not exist. Do I have to create it? And if yes, how?
    Because I do not even have the qbase folder. I try several things that I find on the internet like download mysql.dll .dll and mysqld.dll and put them in the built executable folder.
    I made a little code that tests the connection to the database here.

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
     
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
     
    MainWindow::~MainWindow()
    {
        delete ui;
    }
     
     
    void MainWindow::on_pushButton_clicked()
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setDatabaseName("entreprise");
        db.setUserName("root");
        db.setPassword("pass");
     
        if(db.open()){
            QMessageBox::information(this,"Connection","Database connected");
        }
        else{
            QMessageBox::warning(this,"Not Connected", "not connected");
        }
    }
    

    When the compilation works. Once I press the button. I have the following errors that appear

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    

    Ideas ? Thank you :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Use the Maintenance Tool and download the Qt sources from there.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Raftapss
        wrote on last edited by
        #3

        Thanks for the welcome :)
        I have the maintenance tool. I choose to add a component.
        I already checked Qt5.12.5.
        And I chose in the tools of development and designer:
        Qt creator 4.10.1 CDB Debugger Support
        Debugging tools for windows
        MinGW 7.3.0 32bit and 64bit.
        Should I take something else?

        To come back to the problem, I ended up finding the file

        C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers
        

        Then I added the qmake to the PATH, to execute the command

        qmake -- MYSQL_INCDIR=C:/Program Files/MySQL/include "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 8.0/lib/opt"
        

        An error appears

        ERROR: Invalid command line parameter 'Files/MySQL/include'.
        

        Because I do not have a folder, the folder includes, is located in the 8.0 server folder and 8.0 c ++ connector
        Which one should I use. The command of the documentation is this one

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

        I ask myself another question. What is the "opt" at the end of the order. Because in my file
        C: \ Program Files \ MySQL \ MySQL Server 8.0 \ lib
        there is no "opt" file
        Thank you for helping me :)

        R 1 Reply Last reply
        0
        • R Raftapss

          Thanks for the welcome :)
          I have the maintenance tool. I choose to add a component.
          I already checked Qt5.12.5.
          And I chose in the tools of development and designer:
          Qt creator 4.10.1 CDB Debugger Support
          Debugging tools for windows
          MinGW 7.3.0 32bit and 64bit.
          Should I take something else?

          To come back to the problem, I ended up finding the file

          C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers
          

          Then I added the qmake to the PATH, to execute the command

          qmake -- MYSQL_INCDIR=C:/Program Files/MySQL/include "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 8.0/lib/opt"
          

          An error appears

          ERROR: Invalid command line parameter 'Files/MySQL/include'.
          

          Because I do not have a folder, the folder includes, is located in the 8.0 server folder and 8.0 c ++ connector
          Which one should I use. The command of the documentation is this one

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

          I ask myself another question. What is the "opt" at the end of the order. Because in my file
          C: \ Program Files \ MySQL \ MySQL Server 8.0 \ lib
          there is no "opt" file
          Thank you for helping me :)

          R Offline
          R Offline
          Raftapss
          wrote on last edited by Raftapss
          #4

          To finish I have a result. it goes slowly :)
          Here is the result

          C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=C:/"Program Files"/MySQL/include "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Server 8.0/lib/opt"
          
          Running configuration tests...
          Done running configuration tests.
          
          Configure summary:
          
          Qt Sql Drivers:
            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, you must run 'mingw32-make install'.
          Qt will be installed into 'C:\Qt\5.12.5\mingw73_32'.
          
          Prior to reconfiguration, make sure you remove any leftovers from
          the previous build.
          
          
          C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers>mingw32-make install
          cd odbc\ && ( if not exist Makefile C:\Qt\5.12.5\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\odbc\odbc.pro ) && mingw32-make -f Makefile install
          mingw32-make[1]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          mingw32-make -f Makefile.Release install
          mingw32-make[2]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          copy /y ..\plugins\sqldrivers\qsqlodbc.dll C:\Qt\5.12.5\mingw73_64\plugins\sqldrivers\qsqlodbc.dll
                  1 fichier(s) copié(s).
          C:\Qt\5.12.5\mingw73_64\bin\qmake.exe -install qinstall C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QODBCDriverPlugin.cmake C:\Qt\5.12.5\mingw73_64\lib\cmake\Qt5Sql\Qt5Sql_QODBCDriverPlugin.cmake
          mingw32-make[2]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          mingw32-make -f Makefile.Debug install
          mingw32-make[2]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          copy /y ..\plugins\sqldrivers\qsqlodbcd.dll C:\Qt\5.12.5\mingw73_64\plugins\sqldrivers\qsqlodbcd.dll
                  1 fichier(s) copié(s).
          C:\Qt\5.12.5\mingw73_64\bin\qmake.exe -install qinstall C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QODBCDriverPlugin.cmake C:\Qt\5.12.5\mingw73_64\lib\cmake\Qt5Sql\Qt5Sql_QODBCDriverPlugin.cmake
          mingw32-make[2]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          mingw32-make[1]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          cd sqlite\ && ( if not exist Makefile C:\Qt\5.12.5\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && mingw32-make -f Makefile install
          mingw32-make[1]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          mingw32-make -f Makefile.Release install
          mingw32-make[2]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          copy /y ..\plugins\sqldrivers\qsqlite.dll C:\Qt\5.12.5\mingw73_64\plugins\sqldrivers\qsqlite.dll
                  1 fichier(s) copié(s).
          C:\Qt\5.12.5\mingw73_64\bin\qmake.exe -install qinstall C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake C:\Qt\5.12.5\mingw73_64\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake
          mingw32-make[2]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          mingw32-make -f Makefile.Debug install
          mingw32-make[2]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          copy /y ..\plugins\sqldrivers\qsqlited.dll C:\Qt\5.12.5\mingw73_64\plugins\sqldrivers\qsqlited.dll
                  1 fichier(s) copié(s).
          C:\Qt\5.12.5\mingw73_64\bin\qmake.exe -install qinstall C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake C:\Qt\5.12.5\mingw73_64\lib\cmake\Qt5Sql\Qt5Sql_QSQLiteDriverPlugin.cmake
          mingw32-make[2]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          mingw32-make[1]: Leaving directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/sqlite'
          

          MySql is not ok. Maybe one idea?
          I can read

          mingw32-make[1]: Entering directory 'C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/odbc'
          

          Why dont entering in the existing directory

          C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers\mysql
          

          Maybe the command

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Check the logs, you'll se why the test failed for MySQL.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Raftapss
              wrote on last edited by Raftapss
              #6

              What log do you speak ?
              A command or a way of doing? I'm a beginner :)

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Check for a folder name config.tests and look its content.

                I would use grep or ag for that but I am not sure you have these commands available on your Windows machine.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • R Offline
                  R Offline
                  Raftapss
                  wrote on last edited by
                  #8

                  I dont fine the file config.tests. Where is it ? In Qt or Mysql? i try that

                  @echo off
                  echo Setting up environment forQt usage...
                  
                  set QTDIR=C:\Qt\qt 5.10.1\5.10.1\migw53_32
                  set MINGW=C:\Qt\qt 5.10.1\Tools\mingw530_32
                  set MYSQLCONNECTORDIR=C:\Qt\qt 5.10.1\MYSQL
                  
                  echo Download mysql connector
                  mkdir %MYSQLCONNECTORDIR%
                  cd %MYSQLCONNECTORDIR%
                  powershell -Command"Invoke-WebRequest https://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.11-win32.zip -OutFile mysql-connector-c-6.1.11-win32.zip"
                  unzip -d mysql-connector-c-6.1.11-win32.zip
                  powershell.exe -nologo -noprofile -command "& { $shell = New-Object -COM Shell.Application; $target = $shell.NameSpace($env:MYSQLCONNECTORDIR); $zip = $shell.NameSpace($env:MYSQLCONNECTORDIR + '\mysql-connector-c-6.1.11-win32.zip'); $target.CopyHere($zip.Items(), 16); }"
                  
                  set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
                  cd /D %QTDIR%
                  cd ..\Src\qtbase\src\plugins\sqldrivers\mysql
                  qmake -- MYSQL_INCDIR=%MYSQLCONNECTORDIR%\include "MYSQL_LIBDIR=%MYSQLCONNECTORDIR%\lib"
                  qmake "INCLUDEPATH+=%MYSQLCONNECTORDIR%\\mysql-connector-c-6.1.11-win32\\include""LIBS+=%MYSQLCONNECTORDIR%\\mysql-connector-c-6.1.11-win32\\lib\\libmysql.lib" mysql.pro
                  mingw32-make
                  mingw32-make install
                  

                  But not work... I dont have qsqmysql.dll
                  have an idea?

                  R 1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    What kind of terminal are you using ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • R Raftapss

                      I dont fine the file config.tests. Where is it ? In Qt or Mysql? i try that

                      @echo off
                      echo Setting up environment forQt usage...
                      
                      set QTDIR=C:\Qt\qt 5.10.1\5.10.1\migw53_32
                      set MINGW=C:\Qt\qt 5.10.1\Tools\mingw530_32
                      set MYSQLCONNECTORDIR=C:\Qt\qt 5.10.1\MYSQL
                      
                      echo Download mysql connector
                      mkdir %MYSQLCONNECTORDIR%
                      cd %MYSQLCONNECTORDIR%
                      powershell -Command"Invoke-WebRequest https://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.11-win32.zip -OutFile mysql-connector-c-6.1.11-win32.zip"
                      unzip -d mysql-connector-c-6.1.11-win32.zip
                      powershell.exe -nologo -noprofile -command "& { $shell = New-Object -COM Shell.Application; $target = $shell.NameSpace($env:MYSQLCONNECTORDIR); $zip = $shell.NameSpace($env:MYSQLCONNECTORDIR + '\mysql-connector-c-6.1.11-win32.zip'); $target.CopyHere($zip.Items(), 16); }"
                      
                      set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
                      cd /D %QTDIR%
                      cd ..\Src\qtbase\src\plugins\sqldrivers\mysql
                      qmake -- MYSQL_INCDIR=%MYSQLCONNECTORDIR%\include "MYSQL_LIBDIR=%MYSQLCONNECTORDIR%\lib"
                      qmake "INCLUDEPATH+=%MYSQLCONNECTORDIR%\\mysql-connector-c-6.1.11-win32\\include""LIBS+=%MYSQLCONNECTORDIR%\\mysql-connector-c-6.1.11-win32\\lib\\libmysql.lib" mysql.pro
                      mingw32-make
                      mingw32-make install
                      

                      But not work... I dont have qsqmysql.dll
                      have an idea?

                      R Offline
                      R Offline
                      Raftapss
                      wrote on last edited by Raftapss
                      #10

                      @Raftapss
                      cmd
                      but i have a resutat. In the qt the compilator when i try mysql with just a connect

                      QSqlDatabase: QMYSQL driver not loaded
                      QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                      

                      Now i have the QMYSQL in avaible drivers, but i dont have the driver i dont anderstand[link text]

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        See for example https://forum.qt.io/topic/107997/qt-win10-qmysql-driver-not-loaded or use the forum search function

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved