Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect Qt to MySQL
Forum Updated to NodeBB v4.3 + New Features

Connect Qt to MySQL

Scheduled Pinned Locked Moved Unsolved General and Desktop
25 Posts 5 Posters 8.7k Views 1 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.
  • DetordreurD Offline
    DetordreurD Offline
    Detordreur
    wrote on last edited by
    #7

    I've tried with both.
    This manual gives me a different error :

    C:\qt-everywhere-opensource-src-5.6.0\qtbase\src\plugins\sqldrivers\mysql>mingw32-make
    mingw32-make -f Makefile.Release all
    mingw32-make[1]: Entering directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
    g++ -c -pipe -fno-keep-inline-dllexport -Is:/include -O2 -std=c++0x -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -IC:/Utils/icu32_54_1_mingw492/include -IC:/openssl/include -IC:/utils/postgresql/pgsql/include -IC:\PROGRA~2\MySQL\MYSQLS~1.5\include -IC:\Qt\5.5\mingw492_32\include\QtCore\5.5.1 -IC:\Qt\5.5\mingw492_32\include\QtCore\5.5.1\QtCore -IC:\Qt\5.5\mingw492_32\include\QtSql\5.5.1 -IC:\Qt\5.5\mingw492_32\include\QtSql\5.5.1\QtSql -IC:\Qt\5.5\mingw492_32\include -IC:\Qt\5.5\mingw492_32\include\QtSql -IC:\Qt\5.5\mingw492_32\include\QtCore -I.moc\release -I..\..\..\..\mkspecs\win32-g++  -o .obj\release\main.o main.cpp
    In file included from main.cpp:36:0:
    ../../../sql/drivers/mysql/qsql_mysql_p.h:55:19: fatal error: mysql.h: No such file or directory
     #include <mysql.h>
                       ^
    compilation terminated.
    Makefile.Release:478: recipe for target '.obj/release/main.o' failed
    mingw32-make[1]: *** [.obj/release/main.o] Error 1
    mingw32-make[1]: Leaving directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
    makefile:38: recipe for target 'release-all' failed
    mingw32-make: *** [release-all] Error 2
    
    1 Reply Last reply
    0
    • XardasX Offline
      XardasX Offline
      Xardas
      wrote on last edited by
      #8

      Can you share your paths "INCLUDEPATH+=" "LIBS+=" at this line:
      qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MySQL\lib\libmysql.lib" mysql.pro

      1 Reply Last reply
      0
      • DetordreurD Offline
        DetordreurD Offline
        Detordreur
        wrote on last edited by
        #9

        Yes sure :
        I tried this :
        set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5
        and
        set mysql=C:\Program Files\MySQL\MySQL Server 5.7

        then
        "INCLUDEPATH+=%mysql%include... etc

        the two solutions gives me the same error :

        compilation terminated.
        Makefile.Release:478: recipe for target '.obj/release/main.o' failed
        mingw32-make[1]: *** [.obj/release/main.o] Error 1
        mingw32-make[1]: Leaving directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
        makefile:38: recipe for target 'release-all' failed
        mingw32-make: *** [release-all] Error 2

        I have no folder in C named Mysql, maybe I miss some librairies for MySQL, but I made the complete installation... I don't know ?

        1 Reply Last reply
        0
        • jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #10

          Try with:

          set mysql="C:\Program Files\MySQL\MySQL Server 5.7"
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • DetordreurD Offline
            DetordreurD Offline
            Detordreur
            wrote on last edited by
            #11
            This post is deleted!
            1 Reply Last reply
            0
            • DetordreurD Offline
              DetordreurD Offline
              Detordreur
              wrote on last edited by Detordreur
              #12

              It give me :

              Cannot find file: Files\MySQL\MySQL.
              Cannot find file: Server.
              Cannot find file: 5.7\include.
              Cannot find file: Files\MySQL\MySQL.
              Cannot find file: Server.
              Cannot find file: 5.7\lib\libmysql.lib.
              Cannot find file: mysql.pro.
              

              I don't understand the line "Mysql.h : no such file or directory" in the error text, there is in fact a file named mysql.h in my folder "MySQL server 5.7\include"

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

                Hi,

                The best thing to do is to move your MySQL installation in a folder without any space in the path. Or use the 8.3 notation.

                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
                • DetordreurD Offline
                  DetordreurD Offline
                  Detordreur
                  wrote on last edited by
                  #14

                  I did it, it resolved my first error, but it gives me a new one :

                  My lines :

                  cd C:\qt-everywhere-opensource-src-5.6.0\qtbase\src\plugins\sqldrivers\mysql
                  set mysql=C:\MySQL\MySQL_Server_5.7
                  qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" mysql.pro
                  mingw32-make
                  

                  And the error :

                  mingw32-make[1]: Entering directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
                  g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\qt-everywhere-opensource-src-5.6.0\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ..\..\..\..\plugins\sqldrivers\qsqlmysql.dll .obj/release/main.o .obj/release/qsql_mysql.o .obj/release/moc_qsql_mysql_p.o  C:\MySQL\MySQL_Server_5.7\lib\libmysql.lib -LC:/Qt/5.4/mingw491_32/lib -lQt5Sql542 -lQt5Core542 .obj\release\qsqlmysql_resource_res.o
                  C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Sql542
                  C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Core542
                  collect2.exe: error: ld returned 1 exit status
                  Makefile.Release:81: recipe for target '..\..\..\..\plugins\sqldrivers\qsqlmysql.dll' failed
                  mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysql.dll] Error 1
                  mingw32-make[1]: Leaving directory 'C:/qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/sqldrivers/mysql'
                  makefile:38: recipe for target 'release-all' failed
                  mingw32-make: *** [release-all] Error 2
                  Appuyez sur une touche pour continuer...
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #15

                    Looks like you are trying to build the Qt 5.6.0 sources with Qt 5.4.2 ?

                    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
                    • DetordreurD Offline
                      DetordreurD Offline
                      Detordreur
                      wrote on last edited by
                      #16

                      Yes, I was, so I reinstall Qt 5.6, finally, and I get a (last?) error : The compiler is MSVC 2015, but at the line "nmake", i get a invalid command error
                      So I tried to call vcvarsall.bat, but I doesn't not change anything
                      (Yes i'm really a beginner)

                      1 Reply Last reply
                      0
                      • jsulmJ Online
                        jsulmJ Online
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #17

                        In your previous post I see: mingw32-make
                        That means you was using MinGW. Did you switch to MSVC2015?
                        Did you rerun qmake?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • DetordreurD Offline
                          DetordreurD Offline
                          Detordreur
                          wrote on last edited by
                          #18

                          Yes I have, I desinstalled Qt 5.5, and reinstall Qt 5.6, and now the Qt console is name MSVC 2015, but it don't recognized the line "nmake"...
                          Yes I rerun qmake

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

                            Open a Visual Studio developer console, that will make thing easier. IIRC it should be in one of the subfolder of the Visual Studio Start menu entry.

                            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
                            • DetordreurD Offline
                              DetordreurD Offline
                              Detordreur
                              wrote on last edited by
                              #20

                              I did it : qmake become invalid command, how do I set environnement to avoid it ?

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

                                Either use the full path to qmake or go to the Qt folder and IIRC there's a qtvars.bat file to setup the paths needed.

                                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
                                • DetordreurD Offline
                                  DetordreurD Offline
                                  Detordreur
                                  wrote on last edited by
                                  #22

                                  Ok perfect, I finally made it, but I don't understand where I have to put the dll to run a project with MySQL ?

                                  cfdevC 1 Reply Last reply
                                  0
                                  • DetordreurD Detordreur

                                    Ok perfect, I finally made it, but I don't understand where I have to put the dll to run a project with MySQL ?

                                    cfdevC Offline
                                    cfdevC Offline
                                    cfdev
                                    wrote on last edited by
                                    #23

                                    @Detordreur like all sql plugin -> /sqldrivers

                                    1 Reply Last reply
                                    0
                                    • DetordreurD Offline
                                      DetordreurD Offline
                                      Detordreur
                                      wrote on last edited by
                                      #24

                                      This is what i've done, in the folder of the executable, but when I try to compile this gives me :
                                      (10061) QMYSQL : Unable to connect

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

                                        Isn't it rather when you run your application ?

                                        If it can't connect, did you check your network settings ? Is your database running ?

                                        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

                                        • Login

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