Dear all,
I am trying to access a mysql DB by C++. I have found the following step to add mysql.h library. I am using Dev-c++, Windows Vista, and Appserv. So i cannot find C:\Program Files\MySQL\MySQL Server 5.0\lib\opt. In my mysql directory, there are only bin, data, scripts and share.
Please help because i cannot find guideline of adding mysql.h elsewhere.
Thank you very much.
1 - Download MySQL Server;
Download and install MYSQL Server (current version is 5.0) from
http://www.mysql.com.
It is best to download the windows installer version.
During the install ensure that the C libray api is also installed as well (you may have to select custom install and ensure that it is selected for installation.
Install the server to the default directory C:\Program Files\MySQL\MySQL Server 5.0
test to make sure the server works fine using the test programs that comes with the server.
Check that the include and lib directorys are present.
2 Download and unpack the C++ library
You have already downloaded the C++ library. It would have unpacked the a folder called mysql++-3.0.6
I unpacked mine to the desktop - so my path to this folder is C:\Documents and Settings\andy\Desktop\mysql++-3.0.6
3 Setting up the library for DEV C++
DEV C++ uses mingw compiler. Mingw compiler uses the unix convention for naming libraries - so there is a special step that needs to be done first.
Look in the mysql++-3.0.6 folder for a file called README-MinGW.txt. Look for the section int that readme file called Prerequisite: MySQL C API DLL Import Library
Open a dos box and run the command as given in that section;
Make sure you use your path for where your mysql++-3.0.6 directory is.
So for me that command would look like this:
cd C:\Program Files\MySQL\MySQL Server 5.0\lib\opt
dlltool -k -d "C:\Documents and Settings\andy\Desktop\mysql++-3.0.\libmysqlclient.def" -l libmysqlclient.a
If you did that successfully, in the C:\Program Files\MySQL\MySQL Server 5.0\lib\opt directory you will see a file called libmysqlclient.a.
Now we can continue and build for DEVC++ and mingw.
Still in the dos box - change directories back to your mysql++-3.0.6
and run the command as given in the Building the Library and Example Programs of the README-MinGW.txt file (mingw32-make -f Makefile.mingw).
You shoulld see mingw compiling the library. Go and have a cofee.
Hopefully all will run well.
4 Moving the library (dll fiiles)
Look in the mysql++-3.0.6 directory for a file called install.hta.
Bouble click it to run it (it is an executable file).
A little program will pop up asking you where to to put the library files.
Just leave the the default location at C:\MySQL++ and use the check boxes to select how you want the subdirectorys laid out.
After pressing i-nstall now- you will find the directory C:\MySQL++
has been created.
Look inside this directory and you will see an include directory with the header files.
You will also see one called lib. look inside lib and you will see a mingw directory (if you also compile the VS2008 library you will see a subdirectory for this also).
Inside the mingw directory you will find two files libmysqlpp.a and mysqlpp.dll.
If you only plan to develop using DEVC++ and mingw - then copy mysqlpp.dll to the windows system32 directory.
(You can't do this if you plan to use VS2003/5/8 as well as mingw - because one of the dlls for VS2003/5/8 library has the same name).
I assume you know how to add additional include paths, and import libraries to DEV C++ projects.
Your two main guides for getting this whole thing setup is the
readme.txt and readme-mingw.txt files.
Good luck.