I have searched like crazy and cant find an answer. I am trying to use mysql in my c++ project and have #include mysql.h but I need that directory file. Does one exist? I got all my code set up but zilions of errors because the file is missing. I'm following a tutorial but they dont explain where to get that directory. Any help would be great. Thanks!!
-
possible duplicate of [How to make #include
work?](http://stackoverflow.com/questions/2516187/how-to-make-include-mysql-h-work) – Cody Gray - on strike Apr 18 '12 at 22:09 -
Possible duplicate of http://stackoverflow.com/questions/2516187/how-to-make-include-mysql-h-work ? – Ben Cottrell Apr 18 '12 at 22:11
-
You need to be more specific. "that directory file" doesn't tell us much here. You're obviously on windows, but beyond that... Please give more information. Please post some of the errors generated upon compilation. Show us the most important compiler settings (what libraries are you linking in? which SHOULD you be?) and such. – Kevin Anderson Apr 18 '12 at 22:11
-
What is C++ 2010? Do you mean the new C++ standard C++11 or something else? – 01100110 Apr 18 '12 at 23:42
1 Answers
I know that that I am too late to post the answer, but just documentation purposes and for those who search for the same error.
- Download the mysql server. You can download it from here: http://www.mysql.com/downloads/
Downloading the community server is just enough. Note: choose the zip file. Choose the x32 since the compiler is automatically configured to build with x32 configuration. If you intend to change the compilation configuration to x64, then go ahead and download the x64 zip file.
After download the zip file, create your new blank project. If you are using MSVC++Express2010, Open the project properties | C/C++ | Additional Include Directories. Add the path to the include folder found in the extracted folder.
Copy the library files found in lib folder in the extracted folder to the project directory where you can find your *.cpp files.
Add the following lines to your code:
#include <my_global.h>
#include <mysql.h>
#pragma comment(lib, "libmysql.lib")
Now you are ready to go :)
You can try the code found here to see if things went right or not.

- 3,416
- 2
- 34
- 37