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. fatal error: mysql.h: No such file or directory
QtWS25 Last Chance

fatal error: mysql.h: No such file or directory

Scheduled Pinned Locked Moved Solved Installation and Deployment
12 Posts 5 Posters 9.6k Views
  • 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.
  • L Offline
    L Offline
    LeeH
    wrote on 26 Mar 2017, 17:21 last edited by
    #1

    OS: Windows 10

    Hello, really hope someone can help as i am desperately trying to install the QMYSQL driver. I am aware that there have been tons of posts about this, but my issue is still not resolved and i really don't know why... My mysql.h file certainly does exist, and thus its path is provided for include. I have latest versions of Qt (5.8 with sources) and MySql (5.7). In mysql installation I chose developer default and installation was successful. I will be happy to provide any further information. I ask for anyone that can help please. Thank you.

    in cmd from:

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

    i run:

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

    then mingw32-make as normal.

    i get:

    mingw32-make -f Makefile.Release all
    mingw32-make[1]: Entering directory 'C:/Qt/5.8/Src/qtbase/src/plugins /sqldrivers/mysql'
    g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++1z -fno-exceptions  -frtti -Wall -Wextra
     -Wvla -Wdate-time -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:\Program -IFiles\MySQL\MySQL
     -IServer  -I5.7\include -IC:\Qt\5.8\mingw53_32\include\QtSql\5.8.0 -IC:\Qt\5.8\mingw53_32
    \include\QtSql\5.8.0\QtSql -IC:\Qt\5.8\mingw53_32\include\QtCore\5.8.0 -IC:\Qt\5.8\mingw53_32\include\
    QtCore\5.8.0\QtCore -IC:\Qt\5.8\mingw53_32\include -IC:\Qt\5.8\mingw53_32\include\QtSql -IC:\Qt\5.8\
    mingw53_32\include\QtCore -I.moc\release -IC:\utils\my_sql\my_sql\include -IC:\utils\postgresql
    \pgsql\include -IC:\openssl\include -I..\..\..\..\mkspecs\win32-g++  -o  .obj\release\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.Release:355: recipe for 
    target '.obj/release/qsql_mysql.o'   failed
    mingw32-make[1]: *** [.obj/release/qsql_mysql.o] Error 1
    mingw32-make[1]: Leaving directory 
    'C:/Qt/5.8/Src/qtbase/src/plugins  /sqldrivers/mysql'
    Makefile:38: recipe for target 'release-all' failed
    mingw32-make: *** [release-all] Error 2
    
    K 1 Reply Last reply 26 Mar 2017, 18:37
    0
    • L LeeH
      26 Mar 2017, 17:21

      OS: Windows 10

      Hello, really hope someone can help as i am desperately trying to install the QMYSQL driver. I am aware that there have been tons of posts about this, but my issue is still not resolved and i really don't know why... My mysql.h file certainly does exist, and thus its path is provided for include. I have latest versions of Qt (5.8 with sources) and MySql (5.7). In mysql installation I chose developer default and installation was successful. I will be happy to provide any further information. I ask for anyone that can help please. Thank you.

      in cmd from:

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

      i run:

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

      then mingw32-make as normal.

      i get:

      mingw32-make -f Makefile.Release all
      mingw32-make[1]: Entering directory 'C:/Qt/5.8/Src/qtbase/src/plugins /sqldrivers/mysql'
      g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++1z -fno-exceptions  -frtti -Wall -Wextra
       -Wvla -Wdate-time -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:\Program -IFiles\MySQL\MySQL
       -IServer  -I5.7\include -IC:\Qt\5.8\mingw53_32\include\QtSql\5.8.0 -IC:\Qt\5.8\mingw53_32
      \include\QtSql\5.8.0\QtSql -IC:\Qt\5.8\mingw53_32\include\QtCore\5.8.0 -IC:\Qt\5.8\mingw53_32\include\
      QtCore\5.8.0\QtCore -IC:\Qt\5.8\mingw53_32\include -IC:\Qt\5.8\mingw53_32\include\QtSql -IC:\Qt\5.8\
      mingw53_32\include\QtCore -I.moc\release -IC:\utils\my_sql\my_sql\include -IC:\utils\postgresql
      \pgsql\include -IC:\openssl\include -I..\..\..\..\mkspecs\win32-g++  -o  .obj\release\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.Release:355: recipe for 
      target '.obj/release/qsql_mysql.o'   failed
      mingw32-make[1]: *** [.obj/release/qsql_mysql.o] Error 1
      mingw32-make[1]: Leaving directory 
      'C:/Qt/5.8/Src/qtbase/src/plugins  /sqldrivers/mysql'
      Makefile:38: recipe for target 'release-all' failed
      mingw32-make: *** [release-all] Error 2
      
      K Offline
      K Offline
      koahnig
      wrote on 26 Mar 2017, 18:37 last edited by
      #2

      @LeeH

      Your include for mysql is split into those three part:

      -IFiles\MySQL\MySQL -IServer  -I5.7\include
      

      This is copied from your posted error message. Since you have space in your path, you would need to wrap it with double quotes. This may be a bit tricky with the external command.

      Try this

      qmake "INCLUDEPATH+=""C:/Program Files/MySQL/MySQL Server 5.7/include""" "LIBS+=""C:/Program Files/MySQL/MySQL Server 5.7/lib""" mysql.pro
      

      Not sure if it will work.
      I have also changed all backward slashes to forward slashes. Sometimes qt tools have an issue with the backward slash, since in linux it has a different meaning, those tools are not really happy. In order to avoid these issues you can use windows the forward slash instead. I do it even in general and windows has nowadays no problems with it.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      4
      • L Offline
        L Offline
        LeeH
        wrote on 27 Mar 2017, 23:33 last edited by LeeH
        #3

        Hi, and thanks for your response, and i will be sure to keep your advice in mind. I have solved my problem by going to Postgres, as the driver is already installed in release. Thanks so much for your response though!

        A 1 Reply Last reply 28 Mar 2017, 00:15
        0
        • L LeeH
          27 Mar 2017, 23:33

          Hi, and thanks for your response, and i will be sure to keep your advice in mind. I have solved my problem by going to Postgres, as the driver is already installed in release. Thanks so much for your response though!

          A Offline
          A Offline
          ambershark
          wrote on 28 Mar 2017, 00:15 last edited by
          #4

          @LeeH Silly reason to switch databases. But Postgres is good to use as well as mysql. Mysql is a quite a bit more powerful but if you don't need the power then postgres should be fine.

          Spaces in paths are the bane of my existence. They always cause issues like this. One of the reasons I hate windows so much. They seem to insist on large paths with spaces in them, all the while having massive path limitations (255 chars without special consideration and using the \?\ syntax).. It's just annoying.

          Anyway as @koahnig stated above it's pretty easy to fix since the problem is already identified. Just have to figure out the proper way to escape the spaces in the path. The double quoting suggested may work, or you may need 's. Assuming you even want to try mysql again, postgres should be fine unless you are aiming at enterprise level stuff, which I'm betting you're not.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          1
          • L Offline
            L Offline
            LeeH
            wrote on 31 Mar 2017, 10:58 last edited by
            #5

            @koahnig
            @ambershark

            Hi again, so I after trying postgres with pgAdmin, I decided that I really do want to continue with mysql and qt (i dunno call it preference) so the saga continues... XD

            Anyway I have fixed the original header file problem by reinstalling mysql to the root without spaces. I also installed the 32 bit version as I had previously installed 64 bit. It seemed to be building, but now I got this error telling me permision is denied to lib direcory:

            mingw32-make -f Makefile.Release all
            mingw32-make[1]: Entering directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
            g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\Qt\5.8\Src\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ..\..\..\..\plugins\sqldrivers \qsqlmysql.dll .obj/release/qsql_mysql.o .obj/release/main.o .obj/release/moc_qsql_mysql_p.o  -LC:\utils\my_sql\my_sql\lib -LC:\utils\postgresql\pgsql\lib C:\MySQL\MySQL_Server_5.7\lib -LC:\Qt\5.8\mingw53_32\lib C:\Qt\5.8\mingw53_32\lib\libQt5Sql.a C:\Qt\5.8\mingw53_32\lib\libQt5Core.a -llibmysql .obj\release\qsqlmysql_resource_res.o
            C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find C:\MySQL\MySQL_Server_5.7\lib: Permission denied
            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.Release:65: recipe for target '..\..\..\..\plugins\sqldrivers\qsqlmysql.dll'  failed
            mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysql.dll] Error 1
            mingw32-make[1]: Leaving directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
            Makefile:38: recipe for target 'release-all' failed
            mingw32-make: *** [release-all] Error 2
            

            I don't understand this because my windows account is admin level. I have run cmd as admin, tried setting lib path to environment variables, and checking permissions of folder. Any ideas?

            J 2 Replies Last reply 31 Mar 2017, 11:08
            0
            • L LeeH
              31 Mar 2017, 10:58

              @koahnig
              @ambershark

              Hi again, so I after trying postgres with pgAdmin, I decided that I really do want to continue with mysql and qt (i dunno call it preference) so the saga continues... XD

              Anyway I have fixed the original header file problem by reinstalling mysql to the root without spaces. I also installed the 32 bit version as I had previously installed 64 bit. It seemed to be building, but now I got this error telling me permision is denied to lib direcory:

              mingw32-make -f Makefile.Release all
              mingw32-make[1]: Entering directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
              g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\Qt\5.8\Src\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ..\..\..\..\plugins\sqldrivers \qsqlmysql.dll .obj/release/qsql_mysql.o .obj/release/main.o .obj/release/moc_qsql_mysql_p.o  -LC:\utils\my_sql\my_sql\lib -LC:\utils\postgresql\pgsql\lib C:\MySQL\MySQL_Server_5.7\lib -LC:\Qt\5.8\mingw53_32\lib C:\Qt\5.8\mingw53_32\lib\libQt5Sql.a C:\Qt\5.8\mingw53_32\lib\libQt5Core.a -llibmysql .obj\release\qsqlmysql_resource_res.o
              C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find C:\MySQL\MySQL_Server_5.7\lib: Permission denied
              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.Release:65: recipe for target '..\..\..\..\plugins\sqldrivers\qsqlmysql.dll'  failed
              mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysql.dll] Error 1
              mingw32-make[1]: Leaving directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
              Makefile:38: recipe for target 'release-all' failed
              mingw32-make: *** [release-all] Error 2
              

              I don't understand this because my windows account is admin level. I have run cmd as admin, tried setting lib path to environment variables, and checking permissions of folder. Any ideas?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 31 Mar 2017, 11:08 last edited by jsulm
              #6

              @LeeH said in fatal error: mysql.h: No such file or directory:

              -LC:\utils\postgresql\pgsql\lib C:\MySQL\MySQL_Server_5.7\lib

              First: why do you have PostgreSQL stuff there?
              Second: C:\MySQL\MySQL_Server_5.7\lib is just hanging around without any parameters, why? This way system tryes to execute this path, but since it is a directory it cannot be executed and you see that error message.

              -LC:\utils\postgresql\pgsql\lib C:\MySQL\MySQL_Server_5.7\lib
              

              How did you call configure?
              Are you trying to build from a clean state (looks like you're not)?

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

              1 Reply Last reply
              3
              • L LeeH
                31 Mar 2017, 10:58

                @koahnig
                @ambershark

                Hi again, so I after trying postgres with pgAdmin, I decided that I really do want to continue with mysql and qt (i dunno call it preference) so the saga continues... XD

                Anyway I have fixed the original header file problem by reinstalling mysql to the root without spaces. I also installed the 32 bit version as I had previously installed 64 bit. It seemed to be building, but now I got this error telling me permision is denied to lib direcory:

                mingw32-make -f Makefile.Release all
                mingw32-make[1]: Entering directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
                g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\Qt\5.8\Src\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ..\..\..\..\plugins\sqldrivers \qsqlmysql.dll .obj/release/qsql_mysql.o .obj/release/main.o .obj/release/moc_qsql_mysql_p.o  -LC:\utils\my_sql\my_sql\lib -LC:\utils\postgresql\pgsql\lib C:\MySQL\MySQL_Server_5.7\lib -LC:\Qt\5.8\mingw53_32\lib C:\Qt\5.8\mingw53_32\lib\libQt5Sql.a C:\Qt\5.8\mingw53_32\lib\libQt5Core.a -llibmysql .obj\release\qsqlmysql_resource_res.o
                C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find C:\MySQL\MySQL_Server_5.7\lib: Permission denied
                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.Release:65: recipe for target '..\..\..\..\plugins\sqldrivers\qsqlmysql.dll'  failed
                mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysql.dll] Error 1
                mingw32-make[1]: Leaving directory 'C:/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql'
                Makefile:38: recipe for target 'release-all' failed
                mingw32-make: *** [release-all] Error 2
                

                I don't understand this because my windows account is admin level. I have run cmd as admin, tried setting lib path to environment variables, and checking permissions of folder. Any ideas?

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 31 Mar 2017, 11:11 last edited by
                #7

                @LeeH said in fatal error: mysql.h: No such file or directory:

                -llibmysql

                Also this is wrong:

                -llibmysql
                

                It must be:

                -lmysql
                

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

                1 Reply Last reply
                4
                • L Offline
                  L Offline
                  LeeH
                  wrote on 31 Mar 2017, 13:25 last edited by LeeH
                  #8

                  @jsulm

                  Hi

                  First: I have no idea why postgres stuff is being used here, I wondered the same thing myself... and I had uninstalled postgres (through control panel) prior to my updated post but it never removed the folders

                  Second: the call i make is as in my original post but without spaces and from the root:

                  qmake "INCLUDEPATH+=C:/MySQL/MySQL_Server_5.7/include" "LIBS+=C:/MySQL/MySQL_Server_5.7/lib" mysql.pro
                  

                  I also tried to add libmysql.lib as it is in the lib directory:

                  qmake "INCLUDEPATH+=C:/MySQL/MySQL_Server_5.7/include" "LIBS+=C:/MySQL/MySQL_Server_5.7/lib/libmysql.lib" mysql.pro
                  
                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 31 Mar 2017, 21:39 last edited by
                    #9

                    Hi,

                    Like @jsulm already wrote: your are missing the -L before the path to the lib folder for the LIBS variable.

                    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
                    2
                    • L Offline
                      L Offline
                      LeeH
                      wrote on 31 Mar 2017, 23:59 last edited by LeeH 4 Jan 2017, 00:00
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        LeeH
                        wrote on 1 Apr 2017, 10:46 last edited by
                        #11

                        Hi guys

                        Please ignore my last post I didn't understand what I needed to do for the lib folder. Thanks to @SGaist for clearing that up it has finally compiled without errors! I am new to this sort of thing and didn't really understand.

                        Thanks to all of you for your help!

                        1 Reply Last reply
                        1
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 1 Apr 2017, 19:29 last edited by
                          #12

                          You're welcome !

                          Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

                          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

                          4/12

                          28 Mar 2017, 00:15

                          topic:navigator.unread, 8
                          • Login

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