Mysql h no such file or directory windows

mysql.h file can’t be found

i’m trying to install connection between c++ and mysql in ubuntu 12.04. i’ve installed mysql-client, mysql-server, libmysqlclient15-dev, libmysql++-dev. but when i try to compile the code i got the error: mysql.h there is no such file . i looked in the folders, there is mysql.h file, i can’t understand why it can’t find it. here is my code:

it’s worked, but now i’m facing another error like :

9 Answers 9

The mysql.h file from the libmysqlclient-dev Ubuntu package is located at /usr/include/mysql/mysql.h .

This is not a standard search path for compilers, however /usr/include is.

You’d typically use the mysql.h header in your code like this:

If you don’t want to specify the directory offset in your source, you can pass the -I flag to gcc (If that’s what you are using) to specify an additional include search directory, and then you wouldn’t need to change your existing code.

which will automatically pull the latest libmysqlclient18-dev

I have seen older versions of libmysqlclient-dev (like 15) puts the mysql.h in weird locations e.g. /usr/local/include etc.

otherwise, just do a

and put the folder path of your mysql.h with -I flag in your make file. Not clean but will work.

You probably don’t included the path to mysql headers, which can be found at /usr/include/mysql, on several unix systems I think. See this post, it may be helpfull.

By the way, related with the question of that guy above, about syntastic configuration. One can add the following to your

and you can always check the wiki page of the developers on github. Enjoy!

You have to let the compiler know where the mysql.h file can be found. This can be done by giving the path to the header before compiling. In IDEs you have a setting where you can give these paths.

This link gives you more info on what options to use while compiling.

To your second problem You need to link the libraries. The linker needs to know where the library files are which has the implementation for the mysql functions that you use.

This link gives you more info on how to link libraries.

I think you can try this gcc -I/usr/include/mysql *.c -L/usr/lib/mysql -lmysqlclient -o *

this worked for me

-lmysqlclient is must.

and i would personally recommend to use following notation instead of using -I compilation flag.

For those who are using Eclipse IDE.

After installing the full MySQL together with mysql client and mysql server and any mysql dev libraries,

You will need to tell Eclipse IDE about the following

  • Where to find mysql.h
  • Where to find libmysqlclient library
  • The path to search for libmysqlclient library
Читайте также:  Linux mint ночной режим экрана

Here is how you go about it.

To Add mysql.h

1. GCC C Compiler -> Includes -> Include paths(-l) then click + and add path to your mysql.h In my case it was /usr/include/mysql

To add mysqlclient library and search path to where mysqlclient library see steps 3 and 4.

2. GCC C Linker -> Libraries -> Libraries(-l) then click + and add mysqlcient

3. GCC C Linker -> Libraries -> Library search path (-L) then click + and add search path to mysqlcient. In my case it was /usr/lib64/mysql because I am using a 64 bit Linux OS and a 64 bit MySQL Database.

Otherwise, if you are using a 32 bit Linux OS, you may find that it is found at /usr/lib/mysql

“Cannot open include file: ‘config-win.h’: No such file or directory” while installing mysql-python

I’m trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error reported here, but the answer there worked for me too. Now I’m getting this following error:

If I symlink (Win7) to my regular (not the virtualenv’s) python’s site-packages/MySQLdb dir I get

I’m rather at a loss here. Any pointers?

22 Answers 22

Update for mysql 5.5 and config-win.h not visible issue

In 5.5 config-win. has actually moved to Connector separate folder in windows. i.e. smth like:

C:\Program Files\MySQL\Connector C 6.0.2\include

To overcome the problem one need not only to download «dev bits» (which actually connects the connector) but also to modify mysqldb install scripts to add the include folder. I’ve done a quick dirty fix as that.

in setup_windows.py locate the line

Ugly but works until mysqldb authors will change the behaviour.

Almost forgot to mention. In the same manner one needs to add similar additional entry for libs:

i.e. your setup_windows.py looks pretty much like:

All I had to do was go over to oracle, and download the MySQL Connector C 6.0.2 (newer doesn’t work!) and do the typical install.

Be sure to include all optional extras (Extra Binaries) via the custom install, without these it did not work for the win64.msi

Once that was done, I went into pycharms, and selected the MySQL-python>=1.2.4 package to install, and it worked great. No need to update any configuration or anything like that. This was the simplest version for me to work through.

The accepted solution no longer seems to work for newer versions of mysql-python. The installer no longer provides a site.cfg file to edit.

If you are installing mysql-python it’ll look for C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include . If you have a 64-bit installation of MySQL, you can simply invoke:

  1. mklink /d «C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include» «C:\Program Files\MySQL\MySQL Connector C 6.0.2\include»
  2. Run pip install mysql-python
  3. Delete the symbolic link created in step 1

The accepted answer is out of date. Some of the suggestions were already incorporated in the package, and I was still getting the error about missing config-win.h & mysqlclient.lib.

There’s a zip file for the conenctor too but that didn’t work because mysqlclient.lib is in lib directory whereas the installer expects it in lib/opt . Instead of hacking site.cfg or setup_windows.py, the msi does the job.

pip install mysql-python

P.S. Since I don’t use MySQL anymore, my answer may be out of date as well.

I know this post is super old, but it is still coming up as the top hit in google so I will add some more info to this issue.

Читайте также:  Как удалить фаерволы windows

I was having the same problems as OP but none of the suggested answers seemed to work for me. Mainly because «config-win.h» didn’t exist anywhere in the connector install folder.

I was using the latest Connector C 6.1.6 as that was what was suggested by the MySQL installer.

This however doesn’t seem to be supported by the latest MySQL-python package (1.2.5). When trying to install it I could see that it was explicitly looking for C Connector 6.0.2.

pip install mysqlclient returns «fatal error C1083: Cannot open file: ‘mysql.h’: No such file or directory

Here is this issue: I attempt to install mysqlclient like so

I made sure I had all of the files needed from visual studios build tools, I downloaded the mysql-python connector, and updated my pip and setup tools. I am a complete beginner to this and would appreciate any input as to how to go about fixing this error.

14 Answers 14

You can download unofficial windows binaries for your python version using https://www.lfd.uci.edu/

gohlke/pythonlibs/#mysqlclient. Then install it using pip. This way you’ll be able to avoid the hassle of dealing with visual studio build tools.

Just download the mysqlclient.whl file most applicable to you. I think in your case it’ll be

This error occurs when trying to install mysqlclient for python32 in 64 bit environments. Uninstall python and re-install 64 bit version. Then pip install mysqlclient will run with no errors.

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

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

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

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)\MySQL\MySQL Connector C 6.1\include 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)\MySQL\MySQL Connector C 6.1\lib and do again the same drill for the lib folder
so you should have

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

fatal error: my_global.h: No such file or directory #11

Comments

bezborodow commented Aug 26, 2017

I encounter the following error when attempting to compile Levenshtein-MySQL-UDF:

The text was updated successfully, but these errors were encountered:

bezborodow commented Aug 26, 2017 •

So my guess is that the file my_global.h was moved to the server/ subdirectory in my version or distribution of MariaDB.

This is how I resolved the issue:

juanmirocks commented Aug 27, 2017

Hmm, precisely your distribution configuration should tell you the config paths without making any «hacks».

Читайте также:  Before windows were used

Can you paste the entire output of mysql_config ? Is the server/ directory in any of the options?

Btw, thanks for the hing on using mysql_config —plugindir . That simplifies installation, I included it in the README !

bezborodow commented Aug 27, 2017

system/ doesn’t seem to be mentioned.

juanmirocks commented Aug 27, 2017

Strange. Perhaps there is some minor misconfiguration in your installation.

If you find a generic solution to the problem please let me know. In the meantime, I close the issue.

Thanks for your report!

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

‘mysql/mysql.h’: No such file or directory #619

Comments

OlafvdSpek commented Jan 31, 2017

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

The text was updated successfully, but these errors were encountered:

ras0219-msft commented Feb 1, 2017

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:

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

OlafvdSpek commented Feb 1, 2017 •

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

C:\vc\vcpkg\installed\x86-windows looks fine.

ras0219-msft commented Feb 2, 2017

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

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

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:\vc\vcpkg\installed\x86-windows\include is put on the command line?

OlafvdSpek commented Feb 2, 2017 •

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.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»Debug\T2.pch» /Fo»Debug\» /Fd»Debug\vc140.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 commented Feb 2, 2017

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

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Оцените статью