ArticleSource:Http://blog.csdn.net/likelynn/archive/2007/10/15/1825381.aspx
-
- Download mysql1_2.2.3.tr.gz and decompress it to D: \ mysql ++ 2.2.3
-
- InstallMysql5. 0 server, because it is required during MySQL ++ compilation, You can also download the free installation version on the official website and decompress it to c :\Mysql5. 0
-
- Search for dlltool.exe in the installation path of DEV-C ++ to copy it to c :\Mysql5Under. 0 \ Lib \ OPT
-
- Copy libmysqlclient. Def from D: \ mysql ++ 2.2.3 to c :\Mysql5Under. 0 \ Lib \ OPT
-
- In the command line, enter c: \ mysql5.0 \ Lib \ OPT and execute dlltool-K-d c: \ mysql ++ \ libmysqlclient. def-l libmysqlclient. a. This will generate libmysqlclient. file a (dlltool error, unknown reason)
-
- Copy libmysqlclient. A to D: \ mysql ++ 2.2.3.
- Open it under D: \ mysql ++ 2.2.3Makefile. Mingw, replace the path c: \ Program Files \ mysql \ MySQL Server 5.0 with the local c :\Mysql5. 0 path
-
- Open MySQL ++. BKL under D: \ mysql ++ 2.2.3 and replace the path c: \ Program Files \ mysql \ MySQL Server 5.0 with the local c :\Mysql5. 0 path
-
- In the command line, enter D: \ mysql ++ 2.2.3 and execute: mingw32-make-F makefile. mingw
-
- After step 2 is successful, run install. Bat install on the console to create the c: \ mysql ++ directory.CodeRequired directory
-
- Create a folder lib under c: \ mysql ++, and set libmysqlclient under D: \ mysql ++ 2.2.3. def, libmysqlclient. a, mysqlpp. DLL, libmysqlpp. a, libmysqlpp_util.a copy to lib
-
- In C :\Mysql5In. 0 \ Lib \ opt, find libmysql. dll, libmysql. Lib, copy it to Lib, or include
-
- Set c :\Mysql5Copy all header files under. 0 \ include to D: \ mysql ++ 2.2.3 \ include, or later include files in the project
- Create a project with DEV-C ++, add c: \ mysql ++ to the project's inclusion path, and add files under c: \ mysql ++ \ Lib in the parameter-connector
-
- Add include <MySQL ++. h> and using namespace mysqlpp to the project header file, copy libmysql. dll and mysqlpp. DLL to the project directory, and compile the file successfully!
Code:
# Include <cstdlib>
# Include <iostream>
# Include <MySQL ++. h>
Using namespace STD;
Using namespace mysqlpp;
Int main (INT argc, char * argv [])
{
Connection con = new connection ();
// Create a database connection. The parameters are dbname, svcip, username, and password.
Con. Connect ("collagen", "192.168.0.221 ","*****","*******");
If (! Con)
{
Cout <"Connect failed ~! "<Endl;
}
Else
{
Cout <"Oh. Year ~! "<Endl;
Cout <con. client_info () <Endl; // display client information
Cout <con. host_info () <Endl; // The Connected Server and the protocol used
Cout <con. server_info () <Endl; // Display Server Information
Cout <con. Stat () <Endl; // current server status
}
System ("pause ");
Return exit_success;
}