Mysql h no such file or directory windows

Here is this issue: I attempt to install mysqlclient like so C:Usersamccommon349>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/

Well probably,this is one of the stupidest errors i have ever witnessed.
I have Python 3.7.3 32bit along with latest pip3 and i was installing wheels to my Python….and i stumbled on this STUPID error….
Probably my situation is a bit different but you can resolve it just by looking carefully at the error…. at first it seems something is missing and you start blaming you, Windows ,32/64bit and the list goes on and on..
Take a step back…just take a step back and just read the nasty red error message…. read it really well.
In my case it was

ERROR: Command errored out with exit status 1:
     command: 'c:usersmyUserNameappdatalocalprogramspythonpython37-32python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\MASTER~1\AppData\Local\Temp\pip-install-z7x81g2q\mysqlclient\setup.py'"'"'; __file__='"'"'C:\Users\MASTER~1\AppData\Local\Temp\pip-install-z7x81g2q\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersMASTER~1AppDataLocalTemppip-record-z1mvci5vinstall-record.txt' --single-version-externally-managed --compile
         cwd: C:UsersMASTER~1AppDataLocalTemppip-install-z7x81g2qmysqlclient
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating buildlib.win32-3.7
    creating buildlib.win32-3.7MySQLdb
    copying MySQLdb__init__.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdb_exceptions.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbcompat.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbconnections.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbconverters.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbcursors.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbrelease.py -> buildlib.win32-3.7MySQLdb
    copying MySQLdbtimes.py -> buildlib.win32-3.7MySQLdb
    creating buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstants__init__.py -> buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstantsCR.py -> buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstantsER.py -> buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.7MySQLdbconstants
    copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.7MySQLdbconstants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating buildtemp.win32-3.7
    creating buildtemp.win32-3.7Release
    creating buildtemp.win32-3.7ReleaseMySQLdb
    C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.21.27702binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" -Ic:usersMyUserNameappdatalocalprogramspythonpython37-32include -Ic:usersMyUserNameappdatalocalprogramspythonpython37-32include "-IC:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.21.27702include" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.7ReleaseMySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.21.27702\bin\HostX86\x86\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:usersMyUserNameappdatalocalprogramspythonpython37-32python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\MASTER~1\AppData\Local\Temp\pip-install-z7x81g2q\mysqlclient\setup.py'"'"'; __file__='"'"'C:\Users\MASTER~1\AppData\Local\Temp\pip-install-z7x81g2q\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersMASTER~1AppDataLocalTemppip-record-z1mvci5vinstall-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

Have you read it well ?…i assume that you have everything … the Build tools, the MySQL Connector C 6.1…you even moved it to Program Files (x86)…so what it wrong…?? …
Now take a closer look

C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.21.27702binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" -

I am pretty sure you saw it…STILL NO ?…. let me bold it for you

"-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" -

mariadb
Well it can’t be any stupidest than this …the installer looks for mariadb includes and later libs
Just go to the mariadb site and download the MariaDB C/C++ connector and install it…
Well its not over..
Goto to C:Program Files (x86)MySQLMySQL Connector C 6.1include
and create folder mariadb…and copy paste the contents from the mariaDb connector installation include folder
again don’t go way…go to
C:Program Files (x86)MySQLMySQL Connector C 6.1lib and do again the same drill for the lib folder
so you should have

C:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb  

C:Program Files (x86)MySQLMySQL Connector C 6.1libmariadb  

Now hit the pip3 install mysqlclient
and enjoy installing without a nag…the end

Successfully installed mysqlclient-1.4.2.post1

I am using codeblocks in a windows environment.This is my c code to connect to mysql database.

/* Simple C program that connects to MySQL Database server*/
    #include <mysql.h>
    #include <stdio.h>

    main() {
      MYSQL *conn;
      MYSQL_RES *res;
      MYSQL_ROW row;

      char *server = "localhost";
      char *user = "root";
      //set the password for mysql server here
      char *password = "*********"; /* set me first */
      char *database = "Real_flights";

      conn = mysql_init(NULL);

      /* Connect to database */
      if (!mysql_real_connect(conn, server,
            user, password, database, 0, NULL, 0)) {
          fprintf(stderr, "%sn", mysql_error(conn));
          exit(1);
      }

      /* send SQL query */
      if (mysql_query(conn, "show tables")) {
          fprintf(stderr, "%sn", mysql_error(conn));
          exit(1);
      }

      res = mysql_use_result(conn);

      /* output table name */
      printf("MySQL Tables in mysql database:n");
      while ((row = mysql_fetch_row(res)) != NULL)
          printf("%s n", row[0]);

      /* close connection */
      mysql_free_result(res);
      mysql_close(conn);
    }

I hav an error popping up saying

mysql.h : No such file or directory

When is use c++ in codeblocks, including mysql.h has no issues.But when i do it using c, the above error pops up.

In my previous post, Creating a basic C/C++ Program to Interact with MySQL and MariaDB, I ran into some errors along the way, so I wanted to share those and their resolutions.

1. fatal error C1083: Cannot open include file: ‘mysql.h’: No such file or directory

mysql1.c
mysql1.c(2) : fatal error C1083: Cannot open include file: 'mysql.h': 
No such file or directory

At this point, my cl command was:

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
mysql1.c

So I needed to include the directory that contained mysql.h as well. So the above changed to:

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program FilesMySQLMySQL Server 5.5include" mysql1.c

2. error C2061: syntax error : identifier ‘SOCKET’

This was actually a small slew of simple syntax errors. I could tell it wasn’t the code, so I must have left something else out. Here was the full output/error:

mysql1.c
c:..mysql_com.h(291) : error C2061: syntax error : identifier 'SOCKET'
c:..mysql_com.h(337) : error C2059: syntax error : '}'
c:..mysql_com.h(451) : error C2143: syntax error : missing ')' before '*'
c:..mysql_com.h(451) : error C2143: syntax error : missing '{' before '*'
c:..mysql_com.h(451) : error C2371: 'Vio' : redefinition; different basic types
...
C:..mysql.h(374) : error C2143: syntax error : missing ')' before '*'
C:..mysql.h(374) : error C2143: syntax error : missing '{' before '*'
C:..mysql.h(374) : error C2059: syntax error : ')'
C:..mysql.h(375) : error C2143: syntax error : missing ')' before '*'
C:..mysql.h(375) : error C2143: syntax error : missing '{' before '*'
C:..mysql.h(375) : fatal error C1003: error count exceeds 100; stopping compilation

This plethora of errors indicates we’re missing the windows.h header file:

To fix, add the following to the program (which is already included in the program I provided), and then see #3 below:

#include <windows.h>

3. fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory

mysql1.c
mysql1.c(2) : fatal error C1083: Cannot open include file: 'windows.h': 
No such file or directory

Similar to #1, we need to add another include path, the one that contains windows.h. You can search your system for windows.h with:

dir windows.h /s

For me, this returned:

c:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude

So to fix it, I added it with another /I, so my command became:

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program FilesMySQLMySQL Server 5.5include" 
/I "C:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude" 
/MD "C:Program FilesMySQLMySQL Server 5.5liblibmysql.lib" mysql1.c

4. mysql1.obj : error LNK2019: unresolved external symbol _mysql_close@4 referenced in function _main

In fact, there were 4 similar altogether:

mysql1.obj : error LNK2019: unresolved external symbol 
_mysql_close@4 referenced in function _main
mysql1.obj : error LNK2019: unresolved external symbol 
_mysql_real_connect@32 referenced in function _main
mysql1.obj : error LNK2019: unresolved external symbol 
_mysql_init@4 referenced in function _main
mysql1.exe : fatal error LNK1120: 3 unresolved externals

Turns out this indicates some 32-bit and 64-bit mis-matches.

I had forgot that while I’m on a 64-bit machine, and have 64-bit MySQL already installed (I’m using that header file in my include path), the VS Express is 32-bit. So I need to use a 32-bit header (and different include path), which I downloaded and extracted. So my new command became:

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program Files (x86)MySQLmysql-5.5.30-win32include" 
/I "C:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude" 
/MD "C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.lib" 
mysql1.c

5. The program can’t start because libmysql.dll is missing from your computer

mysql1

mysql1.exe - System Error
The program can't start because libmysql.dll is missing from your 
computer. Try reinstalling the program to fix this problem.
[OK]

In this case, I just wanted to get it built, so I simply copied libmysql.dll and libmysql.lib to this working directory. As I mentioned in my previous post, there is probably a better fix than this, but this worked quickly for now anyway.

6. error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _win_init_registry

Again, in this case, there were several similar unresolved external errors, so let me post them all:

mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _win_init_registry
mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueA@32 referenced in function _win_init_registry
mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _win_init_registry
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__IsValidSid@4 referenced in function ...
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__EqualSid@8 referenced in function ...
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__LookupAccountNameW@28 referenced in function ...
mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__GetTokenInformation@20 referenced in function ...
mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA@20 referenced in function ...
mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext@8 referenced in function ...
mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptGenRandom@12 referenced in function ...
mysql1.exe : fatal error LNK1120: 10 unresolved externals

Fix: Switched from static (/MT) compilation to dynamic (/MD) compilation seemed to fix this:

So the command was (note “/MT …mysqlclient.lib” to “/MD …libmysql.dll”):

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program Files (x86)MySQLmysql-5.5.30-win32include" 
/I "C:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude" 
/MT "C:Program Files (x86)MySQLmysql-5.5.30-win32libmysqlclient.lib" 
mysql1.c

And changed it to:

cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program Files (x86)MySQLmysql-5.5.30-win32include" 
/I "C:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude" 
/MD "C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.lib" 
mysql1.c

7. cl : Command line warning D9024 : unrecognized source file type ‘C:…libmysql.dll’, object file assumed

c:chrismysql1>
cl /I "C:Program Files (x86)Microsoft Visual Studio 10.0VCinclude" 
/I "C:Program Files (x86)MySQLmysql-5.5.30-win32include" 
/I "C:Program Files (x86)Microsoft SDKsWindowsv7.0AInclude" 
/MD "C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.dll" 
mysql1.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 
16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9024 : unrecognized source file type 
'C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.dll', 
object file assumed
mysql1.c
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:libmysql.exe
"C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.dll"
mysql1.obj
C:Program Files (x86)MySQLmysql-5.5.30-win32liblibmysql.dll : 
fatal error LNK1107: invalid or corrupt file: cannot read at 0x368

The problem is trying to use the .dll instead of the .lib, so replace libmysql.dll with libmysql.lib.

That’s all for now.

Hope this helps.

@OlafvdSpek

The vcpkg include dir doesn’t appear to be included.. but I’ve no idea why.
Is this how it’s supposed to look?

vcpkg

@ras0219-msft

That looks correct; we unfortunately at the moment do not show up in the Inherited Values list. I’ve talked to some of our MSBuild people about how we can improve this (and a few other lower priority issues), but it hasn’t been implemented yet.

I pushed some more diagnostics in 8b21933, could you update to (equal or above) that version and rebuild your project with verbosity normal? You should get two extra lines in the output, but only when building with normal or above verbosity:

1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1>Build started 1/31/2017 5:04:50 PM.
1>Target InitializeBuildStatus:
1>  Creating "DebugProject1.tlogunsuccessfulbuild" because "AlwaysCreate" was specified.


1>Target VcpkgTripletSelection:
1>  Using triplet "x86-windows" from "D:srcvcpkginstalledx86-windows"


1>Target ClCompile:
1>  All outputs are up-to-date.
1>  Source1.cpp
1>Target Link:
1>  Project1.vcxproj -> C:UsersroschumaDocumentsVisual Studio 2017ProjectsProject1DebugProject1.exe
1>  Project1.vcxproj -> C:UsersroschumaDocumentsVisual Studio 2017ProjectsProject1DebugProject1.pdb (Partial PDB)
1>Target FinalizeBuildStatus:
1>  Deleting file "DebugProject1.tlogunsuccessfulbuild".
1>  Touching "DebugProject1.tlogProject1.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.95
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Assuming those values are what you expect, the next possibility is that %(AdditionalIncludeDirectories) has been overridden somewhere that the IDE doesn’t report.

@OlafvdSpek



Copy link


Contributor

Author

Got a warning on the first build, but not on the second. Posting here just in case:

Build succeeded.

       "C:vcvcpkgtoolsrcdirs.proj" (default target) (1) ->
       "C:vcvcpkgtoolsrcvcpkgvcpkg.vcxproj" (Build target) (2:2) ->
       (Link target) ->
         C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140Microsoft.CppCommon.targets(638,5): warning MSB5018: Fa
       iled to delete the temporary file "C:UsersOlafAppDataLocalTemptmp94148a16f5b04a1b8236196fa313d1e6.tmp". Th
       e process cannot access the file 'C:UsersOlafAppDataLocalTemptmp94148a16f5b04a1b8236196fa313d1e6.tmp' beca
       use it is being used by another process. [C:vcvcpkgtoolsrcvcpkgvcpkg.vcxproj]

    1 Warning(s)
    0 Error(s)
1>------ Build started: Project: T2, Configuration: Debug Win32 ------
1>Build started 1-2-2017 18:15:21.
1>     1>
1>InitializeBuildStatus:
1>         Touching "DebugT2.tlogunsuccessfulbuild".
1>       VcpkgTripletSelection:
1>         Using triplet "x86-windows" from "C:vcvcpkginstalledx86-windows"
1>       ClCompile:
1>         All outputs are up-to-date.
1>         T2.cpp
1>     1>
1>c:usersolafdocumentsvisual studio 2015projectst2t2.cpp(5): fatal error C1083: Cannot open include file: 'mysql/mysql.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.07
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

C:vcvcpkginstalledx86-windows looks fine.

@ras0219-msft

Ok, to sanity check that the file is where it’s expected, could you run

PS D:srcvcpkg> vcpkg owns mysql.h
libmysql:x86-windows: x86-windows/include/mysql.h

I have an outdated version of libmysql (5.7.16) which put the headers in an incorrect location.

PS D:srcvcpkg> vcpkg list mysql
libmysql:x86-windows        5.7.16           A MySQL client library for C development.

This was fixed in 5.7.17.

Assuming that you have 5.7.17 and x86-windows/include/mysql/mysql.h, could you then run MSBuild in detailed output mode, locate the actual CL.EXE invocation for your project, and confirm that /IC:vcvcpkginstalledx86-windowsinclude is put on the command line?

@OlafvdSpek



Copy link


Contributor

Author

PS C:vcvcpkg> ./vcpkg owns mysql.h
libmysql:x86-windows: x86-windows/include/mysql/mysql.h

PS C:vcvcpkg> ./vcpkg list mysql
libmysql:x86-windows        5.7.17           A MySQL client library for C development.

C:Program Files (x86)Microsoft Visual Studio 14.0VCbinCL.exe /c /I»C:Program Files (x86)Microsoft DirectX SDK (June 2010)Include» /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _SCL_SECURE_NO_WARNINGS /D _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /D _WINSOCK_DEPRECATED_NO_WARNINGS /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yu»stdafx.h» /Fp»DebugT2.pch» /Fo»Debug» /Fd»Debugvc140.pdb» /Gd /TP /analyze- /errorReport:prompt T2.cpp

Found it, I think..
Microsoft.Cpp.Win32.user didn’t have inheritance enabled for the include dir. I’d swear I checked that before though.
Not sure what’s going on, I’d swear too that now that I look at the dialog again it’s different.

Thanks Again, my projects have never linked so cleanly without warnings about mismatched run-times.

@ras0219-msft

Glad to help! Really happy to see warnings being fixed the right way 😄.


  1. Home


  2. Qt Development


  3. Installation and Deployment


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

⚠️ Forum Maintenance: Feb 6th, 8am — 14pm (UTC+2)

This topic has been deleted. Only users with topic management privileges can see it.


  • 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:Qt5.8Srcqtbasesrcpluginssqldriversmysql
    

    i run:

    qmake "INCLUDEPATH+=C:Program FilesMySQLMySQL Server 5.7include" "LIBS+=C:Program FilesMySQLMySQL Server 5.7lib" 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 -IFilesMySQLMySQL
     -IServer  -I5.7include -IC:Qt5.8mingw53_32includeQtSql5.8.0 -IC:Qt5.8mingw53_32
    includeQtSql5.8.0QtSql -IC:Qt5.8mingw53_32includeQtCore5.8.0 -IC:Qt5.8mingw53_32include
    QtCore5.8.0QtCore -IC:Qt5.8mingw53_32include -IC:Qt5.8mingw53_32includeQtSql -IC:Qt5.8
    mingw53_32includeQtCore -I.mocrelease -IC:utilsmy_sqlmy_sqlinclude -IC:utilspostgresql
    pgsqlinclude -IC:opensslinclude -I........mkspecswin32-g++  -o  .objreleaseqsql_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

  • @LeeH

    Your include for mysql is split into those three part:

    -IFilesMySQLMySQL -IServer  -I5.7include
    

    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.


  • 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!


  • @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.


  • @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:Qt5.8Srcqtbasepluginssqldriverslibqsqlmysql.a -o ........pluginssqldrivers qsqlmysql.dll .obj/release/qsql_mysql.o .obj/release/main.o .obj/release/moc_qsql_mysql_p.o  -LC:utilsmy_sqlmy_sqllib -LC:utilspostgresqlpgsqllib C:MySQLMySQL_Server_5.7lib -LC:Qt5.8mingw53_32lib C:Qt5.8mingw53_32liblibQt5Sql.a C:Qt5.8mingw53_32liblibQt5Core.a -llibmysql .objreleaseqsqlmysql_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:MySQLMySQL_Server_5.7lib: 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 '........pluginssqldriversqsqlmysql.dll'  failed
    mingw32-make[1]: *** [........pluginssqldriversqsqlmysql.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?


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

    -LC:utilspostgresqlpgsqllib C:MySQLMySQL_Server_5.7lib

    First: why do you have PostgreSQL stuff there?
    Second: C:MySQLMySQL_Server_5.7lib 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:utilspostgresqlpgsqllib C:MySQLMySQL_Server_5.7lib
    

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


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

    -llibmysql

    Also this is wrong:

    -llibmysql
    

    It must be:

    -lmysql
    

  • @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

  • Hi,

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


  • This post is deleted!


  • 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!


  • 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 :)


Подскажите, не могу подключить заголовочный файл в VS 2013 c++, для работы с MySQL использую MySQL Worсkbench 6.3.
При #include <mysql.h> возникает ошибка:

error C1083: Не удается открыть файл включение: mysql.h: No such file or directory

, как исправить?


  • Вопрос задан

    более трёх лет назад

  • 608 просмотров

Пригласить эксперта

mysql-dev пакет стоит?
пути ищутся относительно include, так что возможно надо указать ещё относительный путь
и не в «кавычках»


  • Показать ещё
    Загружается…

04 февр. 2023, в 20:04

35000 руб./за проект

04 февр. 2023, в 19:43

800 руб./за проект

04 февр. 2023, в 19:05

40000 руб./за проект

Минуточку внимания

96 / 96 / 21

Регистрация: 25.04.2012

Сообщений: 449

1

13.09.2020, 23:29. Показов 23102. Ответов 1


всем привет
сделал всё как по инструкции:
https://www.youtube.com/watch?… e=emb_logo

но пишет
>C:UserstuskasourcereposRHI ConsoleRHI Console.cpp(6,10): fatal error C1083: Не удается открыть файл включение: mysql.h: No such file or directory,

почему?
При этом просто сделал все настройки sql и проекта, и в пустой «хеллоу ворлд» добавил #include <mysql.h>
и все….

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



НВВ

21 / 8 / 5

Регистрация: 12.01.2020

Сообщений: 262

12.10.2020, 21:31

2

Попробуйте «ткнуть комп носом» примерно так:

C++
1
#include <C:/mysql.h>

Укажите путь, где лежит файл mysql.h



0



  • Home
  • Forum
  • Qt
  • Newbie
  • Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or dir

  1. Default Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or dir

    Dear all,
    i got this mistake when compiling driver by seppemagiels instructions on windows.

    what is my mistake?
    this is my Qt and mysql dir:

    C:Qt55.5Srcqtbasesrcpluginssqldriversmysql
    C:MySQLMySQLServer5.5
    both are 32 bit installations on 64bit machine

    I have no spaces in dir name
    I ran prompt as administrator…

    Setting up environment for Qt usage…

    C:Qt55.5mingw492_32>set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5

    C:Qt55.5mingw492_32>cd C:Qt55.5Srcqtbasesrcpluginssqldriversmysql

    C:Qt55.5Srcqtbasesrcpluginssqldriversmysql >qmake «INCLUDEPATH+=%mysql%\include» «LIBS+=%mysql%\lib\libmysql.lib» -o Makefile mysql.pro

    C:Qt55.5Srcqtbasesrcpluginssqldriversmysql >mingw32-make
    mingw32-make -f Makefile.Release all
    mingw32-make[1]: Entering directory ‘C:/Qt5/5.5/Src/qtbase/src/plugins/sqldrivers/mysql’
    g++ -c -pipe -fno-keep-inline-dllexport -Is:/include -O2 -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~2MySQLMYSQLS~1.5include -IC:Qt55.5mingw492_32includeQtCore5.5.1 -IC:Qt55.5mingw492_32includeQtCore5.5.1QtCor e -IC:Qt55.5mingw492_32includeQtSql5.5.1 -IC:Qt55.5mingw492_32includeQtSql5.5.1QtSql -IC:Qt55.5mingw492_32include
    -IC:Qt55.5mingw492_32includeQtSql -IC:Qt55.5mingw492_32includeQtCore -I.mocrelease -I……..mkspecswin32-g++ -o .objreleasemain.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:476: recipe for target ‘.obj/release/main.o’ failed
    mingw32-make[1]: *** [.obj/release/main.o] Error 1
    mingw32-make[1]: Leaving directory ‘C:/Qt5/5.5/Src/qtbase/src/plugins/sqldrivers/mysql’
    makefile:38: recipe for target ‘release-all’ failed
    mingw32-make: *** [release-all] Error 2

    C:Qt55.5Srcqtbasesrcpluginssqldriversmysql >

    Last edited by GoranSimunic; 8th March 2016 at 12:39.


  2. Default Re: Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or

    Quote Originally Posted by GoranSimunic
    View Post

    ../../../sql/drivers/mysql/qsql_mysql_p.h:55:19: fatal error: mysql.h: No such file or directory

    Just to be sure: you’vew verified that mysql.h is in one of the directories you’ve specified as include paths?

    Cheers,
    _


  3. Default Re: Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or

    Im sorry that I do not understand your question well.
    I dont see that I have include mysql.h somewhere

    all I typed in command in prompt is:
    set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5
    qmake «INCLUDEPATH+=C:/MySQL/include» «LIBS+=C:MySQLMySQLServer5.5liblibmysql.li b» mysql.pro
    mingw32-make

    I probably do not understand how did i include mysql.h?

    Dear all,
    sorry for me being superficial…
    I put wrong path to include as you mentioned. This one now is ok.

    qmake «INCLUDEPATH+=C:/MySQL/MySQLServer5.5/include» «LIBS+=C:/MySQL/MySQLServer5.5/lib/libmysql.lib» mysql.pro

    SOLVED so far…now i need to copy dll’s to C:Qt5ToolsQtCreatorbinpluginssqldrivers
    there is no qsqlmysqld.dll in my system, just this one qsqlmysql.dll

    Last edited by GoranSimunic; 8th March 2016 at 14:27.


  4. Default Re: Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or

    Quote Originally Posted by GoranSimunic
    View Post

    Im sorry that I do not understand your question well.
    I dont see that I have include mysql.h somewhere

    I did not ask where you include the header, I asked whether it is in one of the include paths you’ve specified.
    Shouldn’t be too hard to point Explorer to those folders and check the list.

    Quote Originally Posted by GoranSimunic
    View Post

    I probably do not understand how did i include mysql.h?

    When the compiler reports an error, it is usually a good idea to look at the error message.

    Cheers,
    _


  5. Default Re: Build mysql driver for Qt5..5.1 for windows gives error:mysql.h: no such file or

    After building mysql driver is sucesuully done, I understand what you are asking.

    So the answer is:
    yes, I have included the wrong path :-)

    thank you for helping me find mistake.

    driver is built and it is working.


Similar Threads

  1. Replies: 1

    Last Post: 2nd February 2015, 22:44

  2. Replies: 0

    Last Post: 29th May 2014, 08:41

  3. Replies: 1

    Last Post: 4th January 2014, 19:02

  4. Replies: 1

    Last Post: 26th February 2010, 02:02

  5. Replies: 6

    Last Post: 11th January 2010, 14:01

Bookmarks

Bookmarks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.

Like this post? Please share to your friends:
  • Mysql client скачать для windows 10
  • Mysql 2000 скачать на windows 10
  • Mypublicwifi скачать бесплатно на русском языке для windows 7
  • Mypublicwifi не работает на windows 10
  • Mypublicwifi как настроить на windows 10