As far as I know, Mysql Library is not installed automatically for CodeBlocks. Follow some procedures bellow carefully to include mysql library for C++ projects :
- Open Site: devpaks.org/.
- Download libmysql 5.0.5-1sid, hope this library works on Mysql6.
- Rename libmysql-5.0.5-1sid.devpak to file .tar.bz2 extension, then uncompress it with 7Zip or winrar.
- Create an empty folder an name it with mysql.
- Copy the whole folder include to folder mysql where just created.
- Copy that folder mysql dan paste into folder include of MinGW, usually in C:\CodeBlocks\MinGW\include.
- Copy files in folder lib to folder lib of MinGW, usually in C:\CodeBlocks\MinGW\lib.
- Copy file .dll in folder bin to folder where the .exe source code whould build for your project.
- Dont forget to install MySQL befor. (XAMPP recommended).
Lets make some test to make sure that library works:
- Make a New CodeBlocks console program.
- Copy the content of mysql.cpp which located under folder example of uncompressed file .devpak to your new console program.
- Edit Host, User, Pass, Db options to meet your Mysql specification.
- Lets link Mysql library to our program :
- Click CodeBlocks Menu Settings -> Compiler And Debugger -> Global Compiler Settings -> Search Directories Complier: Add C:\Program Files\MySQL\MySQL Server 5.1\include or wherever mysql.h is located.
- Click CodeBlocks Menu Setting -> Compiler And Debugger -> Global Compiler Settings -> Linker Settings -> Link Libraries: add C:\Program Files\MySQL\MySQL Server 5.1\lib\debug\libmysql.lib or whatever libmysql.lib full path is located.
- Type F9 to build and run the program.
Good Luck.
first visit atau kunjunganawal gan salam kenal yah...
ReplyDelete